When used with tickless idle, xTimerStartFromISR()
and xTimerResetFromISR()
might not behave as expected. For reference, these functions capture the current tick count (in the ISR) for use as the start time of the timer. If the ISR happens to interrupt a tickless idle period, the captured tick count isn’t current. It hasn’t yet been corrected by the tickless logic. The correction occurs immediately after the ISR. As a result, the timer is unexpectedly started from a time in the past, possibly in the distant past.
Example: GPIO ISR calls xTimerStartFromISR()
for a 25ms timer
-+----+----+----+----+----+----+----+----+----+----+----+----+----+-
Time (ms) 10 15 20 25 30 35 40 45 50 55 60 65 70 75
Expected Tickless Period |.................................................|
GPIO Interrupt *
Expected Timer Period 25ms |------------------------|
However, the actual behavior (unexpected) is that the timer expires immediately (at Time = 50ms) because the timer logic thinks the start time was Time = 20ms.
If I am understanding this issue correctly, I’m happy to contribute in whatever way is most helpful. I can submit a PR or log an issue for discussion etc. Meantime a simple workaround is to notify a task or pend a function call to start the timer.