Hi,
I have written simple code to creat two tasks, one task is to write to UART (interrupt driven) & another task is to read a character from UART (interrupt driven) & echo back to HyperTerminal to display to the user.
I am using MCF52233-Rev F demo board for testing purpose.
When the control goes to read_task, I have a while loop over there, I want to switch back to write_task, after the timeslice of 1ms is expired.I want to see continuous switching from one task to another, but I am unable to see so.
Please check the code attached & give a feedback as to where I am going wrong.
As per my understanding from MQXUG, if the task is declared as follows, MQX_SCHED_RR else MQX_SCHED_FIFO
const TASK_TEMPLATE_STRUCT MQX_template_list[] = { /* Task Index, Function, Stack, Priority, Name, Attributes, Param, Time Slice */ { READ_TASK, read_task, 1000, 4, "Read", MQX_AUTO_START_TASK, 0, 0 }, { WRITE_TASK, write_task, 1000, 5, "Write", MQX_TIME_SLICE_TASK, 0, 100 }, { 0 }};
But I am unable to see task switching.
Please Help
Thanks
Hello,
I see your task priorities are set to 4 or 5 respectivelly. Priorities less and equal to 7 are running at interrupt levels 0 - 6, priorities above level 7 are running at level 7 (lowest priority, i.re. SR[I] is set to 0). Note that if your task is running at level 4, interrupts with priority 4, 5 and 6 are masked!
Hello,
you don't see task switching, because your write task sends out a character and then it finishes. There should be a loop too. The example itself is kind of fuzzy, for start try simple loops with printf("taskABC") inside.
The task template is also wrong (assuming you wanted time slice), so try this:
const TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
/* Task Index, Function, Stack, Priority, Name, Attributes, Param, Time Slice */
{ READ_TASK, read_task, 1000, 5, "Read", MQX_AUTO_START_TASK | MQX_TIME_SLICE_TASK, 0, 100 },
{ WRITE_TASK, write_task, 1000, 5, "Write", MQX_TIME_SLICE_TASK, 0, 100 },
{ 0 }
};
PetrM