How to create a cyclic task in MQX

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to create a cyclic task in MQX

ソリューションへジャンプ
1,332件の閲覧回数
hbouch
Contributor III

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

タグ(2)
0 件の賞賛
返信
1 解決策
748件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Hugo,

It has been long time since I implemented something like this so please refer to the following PDF:

C:\Freescale\Freescale_MQX_4_1_1\doc\mqx\MQX_Reference_Manual.pdf

Search for "_timer_start_" for various implementations.

Your implementation might want to use:

source\kernel\timer.c

#include <timer.h>

_timer_id _timer_start_oneshot_after(

TIMER_NOTIFICATION_TIME_FPTR notification_function,

void *notification_data_ptr,

_mqx_uint mode,

uint32_t milliseconds)

My example is from MQX3.8 so check that it matches current PDF:

ScreenHunter_163 Jun. 30 10.19.gif

Regards,

David

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
749件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Hugo,

It has been long time since I implemented something like this so please refer to the following PDF:

C:\Freescale\Freescale_MQX_4_1_1\doc\mqx\MQX_Reference_Manual.pdf

Search for "_timer_start_" for various implementations.

Your implementation might want to use:

source\kernel\timer.c

#include <timer.h>

_timer_id _timer_start_oneshot_after(

TIMER_NOTIFICATION_TIME_FPTR notification_function,

void *notification_data_ptr,

_mqx_uint mode,

uint32_t milliseconds)

My example is from MQX3.8 so check that it matches current PDF:

ScreenHunter_163 Jun. 30 10.19.gif

Regards,

David

0 件の賞賛
返信
748件の閲覧回数
hbouch
Contributor III

Hi David,

You're right, "_timer_start_" seems simpler. I looked at MQX reference manual and I think using "_timer_start_periodic_every" would be best suited for me. I could also use "_task_ready" as notification function and task descriptor pointer as pointer to the data that MQX passes to the notification function. At the end of my tasks I would need to use "_task_block".

I will try that thanks!

Regards,

Hugo

0 件の賞賛
返信