Which is the right way to start a one-shot timer?

I created a timer using xTimerCreateStatic(), setting period to pd_MS_TO_TICKS(500). Then later I started the timer with xTimerStartFromISR and found that the timer callback function was immediatelly executed. I changed to using xTimerChangePeriodFromISR, setting period (again) to pd_MS_TO_TICKS(500).
Is that intended behaviour? I would have expected xTimerStartFromISR to also start a 500 msec interval.
Thanks for any help

Is that intended behavior?

… if the timer is not stopped, deleted, or reset in the mean time, the callback function associated with the timer will get called 'n 'ticks after xTimerStart() was called, where ‘n’ is the timers defined period. …

What FreeRTOS port/ HW arch are you using? Does the ISR that calls xTimerStartFromISR() has the logical priority less than or equal to configMAX_SYSCALL_INTERRUPT_PRIORITY ?

Also, how did you verify that the callback is called immediately called after xTimerStartFromISR()?

Hello tony josi,
I read these lines too, but found something else, thats why I ask.
I am working with STM32G0B0 = ARM Cortex M0+ and FreeRTOS 10.5.1. I think interrupt priorities don’t play a role here (??). I don’t have configMAX_SYSCALL_INTERRUPT_PRIORITY defined.
I found out by sending a message via UART. I made sure in the isr that all bytes are out before leaving the isr. Also I send a message from the timer callback, also making sure that all bytes are out before leaving the callback function. I use a terminal program (YAT) that displays the time for each line. The difference is quite clear to see, just checked it again.
Any help is welcome (while currently I am happy with xTimerChangePeriodFromISR)

I don’t know about intended behavior, but it is explainable behavior that xTimerStartFromIsr() and xTimerResetFromIsr() behave as you observed in tickless idle.

The forum has a couple of different threads that explain. Here is a good one where I managed to save all of humanity:

Another one. Although the diagram no longer looks right (in my browser at least).

Hi Jeff,
thanks for your answer and the info, I hope to keep it in mind.
Yes, I’m fine with xTimerChangePeriodFromISR.


It does seem a little odd to have to call xTimerChangePeriodFromISR(). Since this issue has come up a couple of times, here’s a possible fix for combining tickless idle and xTimerStartFromISR().

If there is interest I am happy to open a PR.