2013-11-13 04:07 AM
Hi everyone,
I'm currently working on a musical (using midi) project on which i need very precise delay in order to synchronise with other instruments. This delay should be able to be accurate at 1 microsecond. For instance, i have ''overclocked'' FreeRTOS increasing configTICK_RATE_HZ from 1000 to 1000000. And i have a cylclic task (using vTaskDelayUntil()) trigerred each 5208 microseconds (for 120 beats per minute). Obviously increasing configTICK_RATE_HZ is not a good idea and anyway i don't get the accuracy i wanted. If i synchronise with another instrument for a BPM of 120 i get approximatively 119,80. For you what is the best way to get such accuracy ? Using an hardware timer and trigger interrupts ? Is it really impossible to run correctly FreeRTOS at this tick rate..? thanks, Ben #us-delay-stm32f4 #us-delay-stm32f4 #tim2013-11-13 06:55 AM
As you have discovered the FreeRTOS soft timer isn't really a good choice for high resolution timing. You would be better off using one of the hardware timers and synching with interrupts running above the FreeRTOS kernel (no API calls). I do this for stepper motor timing where the jitter in step timing has to be under 50usec.
Using the tick time you are subject to both the task context switch and interrupt latency times. If you go the hardware TIM timer route and assign the TIM interrupt to a high priority you will bypass all the latency problems. Jack Peacock2013-11-15 04:22 AM
As you said it's better to use hardware timers for very precise times. I have implemented it with a binary semaphore to unblock my task when timer interrupt occurs. I can change the period of the timer by changing the ARR register. It's exactly what i wanted !
Thanks a lot for your reply,