cancel
Showing results for 
Search instead for 
Did you mean: 

STM FreeRTOS micro, nano second delay

StanCosgrove
Associate II

I m using FreeRTOS functions and discovered that the osDelay could only works on mini second, anyway to perform at micro second and nano second delay? If i create a micro second delay using timer TIM1 will that satisfy real-time prerequisite? Anyone can advise? 

1 REPLY 1

You're not going to be able to interrupt at these high rates.

Take a 32-bit TIM, say TIM2 or TIM5, program it in maximal mode, and a prescaler of 0 (DIV1), and then use TIMx->CNT to observe time counting off.

Get an initial value, and subtract if off the current value, and wait for it to count off the precribed number of ticks for the rate it is counting at.

It's going to count in multiple nano-seconds, and if the MCU goes off to service an interrupt it might be off doing that for a few micro-seconds.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..