Timers: how to set the next delay in the callback
Posted: Tue Jun 19, 2018 10:59 pm
Hi,
I need a repetitive timer, with variable interval. I want the next interval be set in the timer callback. I.e. when the timer fires, I decide when to fire it next.
I implemented it using ChibiOS GPT. I start the timer with gptStartContinuous(), and set the next interval with gptChangeIntervalI() from the timer callback procedure.
The problem is that at the moment I call gptChangeIntervalI(), the next interval is already counting, and its length is not affected by the call. So the interval change is applied at the end of this next interval only.
Obviously, I can do that by creating a task and use the chThdSleepMilliseconds() or like.
But does anybody know how to implement this without allocating a task for it?
Regards,
Vladimir
I need a repetitive timer, with variable interval. I want the next interval be set in the timer callback. I.e. when the timer fires, I decide when to fire it next.
I implemented it using ChibiOS GPT. I start the timer with gptStartContinuous(), and set the next interval with gptChangeIntervalI() from the timer callback procedure.
The problem is that at the moment I call gptChangeIntervalI(), the next interval is already counting, and its length is not affected by the call. So the interval change is applied at the end of this next interval only.
Obviously, I can do that by creating a task and use the chThdSleepMilliseconds() or like.
But does anybody know how to implement this without allocating a task for it?
Regards,
Vladimir