This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiple application timer instances or multiple counters in one instance, what is the best way?

Let suppose using the dynamic multiprotocol ZigBee + Softdevice application with OTA upgrade possibility. I would like to use the app_timer (along with app_scheduler) to trigger some actions every 1ms, 20ms, 100ms, and 3s. Is it right, if I will use separate timer instance for each periodic trigger (so, it gives 4 instances for mentioned case)? Or, maybe the better case to use only one instance for the lowest period of 1ms, and use counters for the rest inside the single handler?

Also, does the 1ms periodic triggering by app_timer the good idea in general? 5 ticks of RTC1 are about the 0.15ms, so 1ms fulfill this requirement, but without great superiority. The other options not involved in the Zigbee stack and Softdevice are Timer 2 and Timer 4, but they are used already for other time-related tasks with peripheral in the project.

Parents Reply Children
  • Hi.

    The time resolution of RTC1 is okay for my task as for 1ms trigger, and others, that have no strict time precision requirements so even up to 1 ms deviations are acceptable for 20ms, 100ms, and 3s triggers.

    Also, I use app scheduler mode in order to spend less time in the interrupt handler, that can lead to some little additional delays in trigger function actual call, but it is also okay even for 1ms, I believe. However, I wondered, what if all 4 trigger functions will be scheduled in queue simultaneously (for example, on 3s interval)? I can select non-devisors as trigger intervals, but anyway, such a situation with queue would still possible for some times.

    So, as you advised, I would use one app_timer instance for all of these intervals and would further think, how to avoid 1ms triggering by app_timer.

    Sincerely,

    Anna

Related