Task Argument

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Task Argument

2,226 次查看
w2vy
Contributor V

I have a task that I need to run on two serial ports.

 

The same operations on both ports.

 

I tried using the Task Parameter from the Task Template but it didn't seem to work.

 

TASK_TEMPLATE_STRUCT MQX_template_list[] ={/*  Task number, Entry point, Stack, Pri, String, Auto? */   {MAIN_TASK, Main_task,   3000,  9,   "main",  MQX_AUTO_START_TASK, 0, 50},   {TTYA, serial_app,  3000,  9,   "TTYA", MQX_TIME_SLICE_TASK, 0, 50},   {TTYB, serial_app,  3000,  9,   "TTYB", MQX_TIME_SLICE_TASK, 1, 50},   {0,           0,           0,     0,   0,             0,     0, 0}};

 

I have the task argument for TTYA set to 0 and TTYB set to 1

 

Each time serial_app starts the argument is 0

 

What am I missing?

 

tom

ps. I am using MQX 3.6

标记 (2)
0 项奖励
回复
6 回复数

1,427 次查看
anthony_huereca
NXP Employee
NXP Employee

The argument in the Task Template List is only used if the MQX_AUTO_START_TASK attribute is set for that task.

 

Since your two serial tasks (TTYA and TTYB) do not have the auto start attribute set, it means at some point in your main code you have to call task_create.

 

The 3rd argument in that task_create() function call over-rides the initial data argument in the Task Template List. So you should be calling it like so:

_task_create(0,TTYA,0);

_task_create(0,TTYB,1);

 

See page 358 of the MQX Reference Manual for more details than you'd ever want to know on the task_create function.

 

-Anthony

 

 

1,427 次查看
w2vy
Contributor V

That is what I tried and it did not work for me.

I just ran a test with a different task and it did work fine...

I will retest with the original code and see what I had wrong...

 

tom

0 项奖励
回复

1,427 次查看
anthony_huereca
NXP Employee
NXP Employee

One thing you might want to double check is that your TTYA and TTYB task id's are unique. That could have also caused your problem in the code.

0 项奖励
回复

1,427 次查看
w2vy
Contributor V

Can't I just have a Task Template Entry for TTY and create two of them with ARG=0 and ARG=1?

 

tom

0 项奖励
回复

1,427 次查看
PetrM
Senior Contributor I

Try to set the priority of main task higher, like 8. You'll have to start there those other tasks (as written above) and then block the main task to release processor time for them.

 

PetrM

 

0 项奖励
回复

1,427 次查看
anthony_huereca
NXP Employee
NXP Employee

You're correct. I was just refering to the MQX_template_list in the sample code in your original post.

 

-Anthony

 

0 项奖励
回复