Timer callback intrval accuracy

joe_her wrote on Tuesday, October 25, 2016:

I wonder what accuracy can I get for the intrvals of the timer callback routine.
For example if I set it to 100 ms, System tick is 1ms, and the callback is short, how many ticks will it miss(if any)?
Is it better, or is it the same as read system ticks and wait with taskDelayUntil() in a task loop (instead of using timer callback)?

edwards3 wrote on Tuesday, October 25, 2016:

The accuracy is set by the tick frequency and the priority of the timer service task relative to other tasks.

All timing, including when a timer callback function is executed, is limited by the granularity of the configured tick frequency.For example if you block a task for 10 ticks and the task enters the blocked state immediately before a tick interrupt the time the task blocks for will be closer to 9 ticks than 10, maybe 9.05 ticks. If instead the task entered the block state immediately after a tick interrupt the time the task blocks for could be 9.999 ticks.

joe_her wrote on Wednesday, October 26, 2016:

I can set normal task priority, but I don’t see how to set a software timer priority that runs a call back function.
So if I need a function that will run every 100 ms, and I can tolerate some +/- gittter on the interval, but would like that the average time will be as accurate as possible (that is after 1000 seconds it will run 10000 times), what is the best way to implement it? (softwre timer? waitUntil? or any other idea…)

rtel wrote on Wednesday, October 26, 2016:

See http://www.freertos.org/RTOS-software-timer.html and in particular
the description of configTIMER_TASK_PRIORITY on