Author Topic: Multiple Mono Timers  (Read 8839 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Multiple Mono Timers
« 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

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Multiple Mono Timers
« Reply #1 on: October 21, 2007, 12:24:18 PM »
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.