µTasker Forum
µTasker Forum => µTasker general => Topic started by: neil on October 21, 2007, 11:18:28 AM
-
Hi Mark,
Is it okay to have multiple MonoTimers at the same time? Is so, what is the maximum number?
I have the following 2 second timer in one task.
uTaskerMonoTimer( OWN_TASK, (DELAY_LIMIT)(2*SEC), E_TIMER_TIMEOUT );// start monitor timer
I would like to add another one to another task,so both will be operating at the same time,as follows:
uTaskerMonoTimer( COMMS_TASK, (DELAY_LIMIT)(60*SEC), E_TIMER_TIMEOUT );// start monitor timer
so during the 1 minute timer, the 2 second one may be executed at the same time on another task.
Regards
Neil
-
Hi Neil
Each task can have one monostable timer of its own. These do not distrurb each other so your example is a suitable solution.
The task timer has to be be defined to be availabe for each task - this is done in the task configuration, where a start up delay or repetition is specified (this automatically creates the timer belonging to the task) or else by reserving one by declaring the start up delay as (DELAY_LIMIT)(NO_DELAY_RESERVE_MONO).
In many cases a single monostable timer per task is perfectly adequate as it often makes sense to have different tasks monitoring different timeouts (code readability and maintainability).
If a single task requires more capabilities it can make use of the GLOBAL_TIMER_TASK. This allows it to use multiple monostable timers (which can be either software based with a resolution equal to the sytem TICK or hardware based with very high resolution - by using GLOBAL_HARDWARE_TIMER). When using the muli-timer support the maximum amount of these timers which can operate in parallel - for the whole system - is defined by TIMER_QUANTITY.
There is demo code in the project illustrating how to use these timers (see TEST_GLOBAL_TIMERS in application.c) and also a guilde at
http://www.utasker.com/docs/uTasker/uTaskerTimers.PDF
Good luck
Regards
Mark
PS. Although a rather specific use, the M5223X RTC interrupt can also be used to generate timer delays or periodic events.