Info |
---|
This section refers to the following sample application(s):
|
The Timers section details the modifications done to timers implementation of uC/OS-II to ensure ultra low-power operation. It also highlights the two different approaches of delaying the execution of one of your tasks. We recommend you go over the Timers section before reading this section.
The 00-uc_timers
Sample Application
The 00-uc_timers
sample application creates two independent tasks (called timerATask
and timerBTask
). Each of these tasks continuously waits, and prints the letter "A" or "B" over the CLI.
This application runs without your intervention, and does not connect to the
Include Page | ||||
---|---|---|---|---|
|
To run the 00-uc_timers
sample application, program your
Include Page | ||||
---|---|---|---|---|
|
No Format |
---|
uc_timers app, ver 1.0.0.2
SmartMeshIP stack, ver 1.2.1.5
ABABABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABA
BABABABABABABABABAABABABABABABABABABABABABABABABABABABABABABAABABA
BABABABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABAB
ABABABABABABAABABABABABABABABABABABABABABABABABABABABABAABABABABAB
ABABABABABABABABABABABABABABABABAABABABABABABABABABABABABABABABABA
BABABABABAABABABABABABABABABABABABABABABABABABABABABAABABABABABABA
BABABABABABABABABABABABABABAABABABABABABABABABABABABABABABABABABAB |
While both tasks perform similar functions, the way the delay is implemented is different:
timerATask
callsOSTimeDly()
as part of its own task context. This causes the uC/OS-II scheduler to pause the execution of the task for the specified amount of time.Note As detailed in the Timers section, when the
OSTimeDly()
is executing, a semaphore is used. You need to account for this when provisioning for the number of Event Control Blocks (ECBs) your application is using.In its initialization section, the
timerBTask
creates a timer using theOSTmrCreate()
function. This timer is set to fire periodically, and call thetimerB_cb()
function each time it does. The only thing this callback function does is post a semaphore. In its main loop, the thetimerBTask
pends on that semaphore at each iteration, causing it to loop at the required rate.Tip This implementation is an example of the "best practice" rules highlighted in the Timers section, i.e. the body of the
timerB_cb()
callback function executes quickly, and does not reserve a large amount of memory on the stack space of the "timer task".