I’ve some mysterious problems with the xTaskDelay function. I start a task an everything runs until the xTaskDelay()-function is called and never returns.
But if I create a “do-only-i++”-task with a priority set to tskIDLE_PRIORITY+1 and set the other task to tskIDLE_PRIORITY+2, everything runs normal.
I don’t know, that isn’t the way it should work, is it?
By the way, I use a LPC2106 Board, GCC4.1.1 and FreeRTOS V3.2.3.
So, if someone have a good guess, what might be wrong, all answers are welcome.
Thanks.
I create a task:
-> xTaskCreate(v_task_Heartbeat,(const signed portCHAR * const) "heartbeat", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, &x_task_Heartbeat_Handle);
which should do:
->void v_task_Heartbeat(void *pvParameters)
{
pvParameters = 0;
HEARTBEAT_LED_PORT = HEARTBEAT_LED; // set to output
// endless loop
for(;
{
vTaskDelay(HEARTBEAT_LED_DELAY); // wait for 500 ticks (0.5s)
HEARTBEAT_LED_PORT_CLR = HEARTBEAT_LED; // turn on LED
vTaskDelay(HEARTBEAT_LED_DELAY); // wait for 500 ticks (0.5s)
HEARTBEAT_LED_PORT_SET = HEARTBEAT_LED; // turn off LED
}
}
I use openocd to debug the program and when i reach the line: vTaskDelay(…), the programm jumps into the function. My task get delayed, but never wake up. When i step further the programm calls the Idle-Task an check if there are other task ready to run. Then i let the programm continue and after a short time i hold it. The programm now has reached an abort-error-loop.
Now i increase the Task-Priority to 2 and create a new task:
->void v_task_idle_2(void *pvParameters)
{
pvParameters = 0;
u32 i;
// endless loop
for(;
{
i++;
}
}
with a Priotity of tskIDLE_PRIRITY+1. If i run this programm, everything seems to run normal an my LED is blinking.
I don’t use an idle hook.
By creating a second idle task that never blocks, you are soaking up all the available CPU so prvIdleTask is never executed. That seems to make it work. So I would then guess that the problem lies in prvIdleTask.
But in your configuration the prvIdleTask in tasks.c will do nothing at all if you create no tasks at tskIDLE_PRIORITY - are you sure you don’t have such tasks also defined?
It all sounds like either an interrupt going astray or perhaps your SWI handler not being setup properly and thus you’re getting aborts when trying to execute garbage?
Hello Robin,
thanks for your answer. I checked the tasks.c, the interrupt routines and a few other functions, and there was nothing. While searching the code, i found a bug in my own code. (Actually i searched my own code a few times but didn’t saw it before). Now everything seems to work fine. (until the next bug )