I have a code for the micro-controller in C.
Basing on the examples I have, I use the function “void osSleep(tU32 ticks)” to stop the program for a while. Unfortunately, I don’t know how it really works and what it does to my micro-controller (what pins, states etc. are set to what values).
I have figured out the setBuzzer() function because I have it’s source:
void setBuzzer(tBool on)
{
if (TRUE == on)
IOCLR = BUZZER_PIN;
else
IOSET = BUZZER_PIN;
}
So the GPIO port is set to 1 or 0 for the PIN related to buzzer (BUZZER_PIN = 0x00002000). Buzzer has one pin so I can just enable and disable it (high and low voltage).
I would like to make similar analyse for osSleep(), but what’s strange, I cannot find it’s implementation in the whole code, only declaration:
void osSleep(tU32 ticks);
Maybe that function is in some library. Anyway, I want to know how it really works on the lower level (e.g. what happens with the timer when I call it, what instructions are execute – like in the buzzer example).
Also, there is only a high-level short definition in the documentation for the code called “Pre-emptive Operating System v 1.4.0” by Embedded Artists.
Without access to the source, there’s no way to be sure. Try using a disassembler (GNU’s
binutilshasobjdump, e.g.) to understand what the actualosSleepdoes.In all likelihood, it’s pending on a semaphore that will get toggled (directly or indirectly) by the timer tick ISR. Your question is interesting, though — the documentation mentions nothing other than “This function puts a process to sleep for the specified number of ticks.” but it certainly could put the entire uC into a lower-power mode if none were available to run.