I have a trivial program with two tasks running at the same priority in MQX Lite, when one of the tasks executes a _time_delay_ticks(10) the other task is correctly swapped to and runs code like this:
while(1) {
_sched_yield();
SEGGER_RTT_WriteString(...);
}
The task will loop about 20 times and then freeze and the other task is never run again. Removing the SEGGER_RTT call makes no difference.
If I replace the _time_delay_ticks() call in the first task with _sched_yield() then everything works fine but without the delay of course.
My spider senses are telling me that maybe I have something configured wrong with the system clocks (I'm using processor expert and a custom k20 board).
Does that seem likely and if so, what is the simplest clock configuration I can use to get to a working state, or are there any common gotchas involved with tasks and _time_delay_ticks.
Thanks!
Jeremy
I had the same problem and it turned out that I had misunderstood the task priority numbering in Processor Expert so the task priority was actually too high which in effect disabled MQX task switching.
Try to set the priority very low (high number) and see if that makes a difference.
Hi Jeremy:
Please refer to the attached document, it is about how to setup kinetis clock using PE.
I think you can use _time_delay_ticks in multiple tasks like this
// task 1 while 1 loop
while(1) {
counter++;
_time_delay_ticks(50);
/* Write your code here ... */
.....
}
// task 2 while 1 loop
while(1) {
counter++;
_time_delay_ticks(250);
/* Write your code here ... */
.......
}
Have a nice day,
Daniel