AnsweredAssumed Answered

How to create a cyclic task in MQX

Question asked by Hugo Bouchard on Jun 30, 2015
Latest reply on Jul 1, 2015 by Hugo Bouchard

Hi,

 

Is there a simple way of creating a cyclic task in MQX?

 

The _time_delay(xx) function isn't really what I'm looking for since it doesn't take into account the execution time of the task. So, with this delay function, if I want a 5 ms cyclic task for example and this task takes 1 ms to execute, my task would be executed every 6 ms and not 5.

 

If we take the same example above, what I would like is that 4 ms after execution of the task (which last 1 ms), the task would become ready again. I could just call _time_delay(4) but the execution time of the task isn't constant.

 

I though about creating a task queue and a lwtimer event queue with a lwtimer that calls a callback function when it expires. This callback would simply call _taskq_resume(). At the end of the task execution the task would call _taskq_suspend().

 

It seems complicated just to do something that should be very simple. Is there another way and simpler way of doing this?

 

Thanks

Outcomes