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.
00-uc_timers
Sample ApplicationThe 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 network.
To run the 00-uc_timers
sample application, program your and open a terminal client on the CLI serial port. After the banner, you will see a continuous stream of "A" and "B" characters, indicating that the uC/OS-II kernel is constantly switching execution between the two tasks.
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
calls OSTimeDly()
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.
As detailed in the Timers section, when the |
In its initialization section, the timerBTask
creates a timer using the OSTmrCreate()
function. This timer is set to fire periodically, and call the timerB_cb()
function each time it does. The only thing this callback function does is post a semaphore. In its main loop, the the timerBTask
pends on that semaphore at each iteration, causing it to loop at the required rate.
This implementation is an example of the "best practice" rules highlighted in the Timers section, i.e. the body of the |