Skip to main content
Visitor II
January 3, 2024
Question

STM FreeRTOS micro, nano second delay

  • January 3, 2024
  • 1 reply
  • 1388 views

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? 

    This topic has been closed for replies.

    1 reply

    Graduate II
    January 3, 2024

    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.