Only first created task runs - WinAVR port

gerardo_rosiles wrote on Wednesday, April 28, 2010:

Based on the examples from the book, I created a program with three tasks and a queue. The fist task  receives numbers from the queue and does printf to the  terminal.  The second receives numbers from the terminal and places them on the queue.  The third just flashes some LEDs.

The priorities are 3, 2 and 1 respectively.

The program only executes one task, which is that task that is created first in main(). I figured this out after commenting xTaskCreate(…) calls and seeing that the next task took over the execution. I hav tried taskYIELD() and vTaskDelay() to see if I can force a switch and nothing happens.

For instance, I know first task should block waiting for the second task to post something on the queue. It does block (tried portDELAY_MAX, and other values. However there is no context switch to the second task.

On the second task I have used vTaskDelay() to let the third task run and it does switch.

If I shuffle the xTaskCreate(…) statements in main, only the fist task created  gets executed even if it has the lowest priority!

I feel I am not configuring something correctly. However I do have the following on FreeRTOSConfig.h

#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1 

Any help would be appreciated.



gerardo_rosiles wrote on Wednesday, April 28, 2010:

I just checked the value returned by xTaskCreate on all three instances I get pdTRUE. So no memory problems(?).

gerardo_rosiles wrote on Wednesday, April 28, 2010:

Well, I think writing your frustations in the forum works! It ocurred that a stack depth size of 10000 could be quite large for an Atmega32 so I cut it to 200, and now my program is working.

The minimal stack size for the ATmega port is set at 85.

Now I would like to understand what was going on?  According to xTaskCreate the tasks were created, however it seems that the stack space was depleted after the first task creation (???).

Could this be a bug in FreeRTOS? or please illiustrate my ignorance :).