2019-04-19 03:38 AM
Hi all,
I am working on stm32l486 chip.
When I created (using CubeMx) two tasks with a stack size equal to 256 words. The project is running well:
osThreadDef(Task1, vTask1, osPriorityNormal, 0, 256);
Task1Handle = osThreadCreate(osThread(Task1), NULL);
osThreadDef(Task2, vTask2, osPriorityNormal, 0, 256);
Task2Handle = osThreadCreate(osThread(Task2), NULL);
The problem appears when I added a third task with a stack size equal to 256:
osThreadDef(Task3, vTask3, osPriorityNormal, 0, 256);
Task3Handle = osThreadCreate(osThread(Task3), NULL);
If I reduce the stack size of each Task to 128, the problem disappear.
Why I can't use 3 tasks with a stack size equal to 256 for each task ?
2019-04-19 04:58 AM
https://www.freertos.org/a00125.html
If a task is created using xTaskCreate() then the required RAM is automatically allocated from the FreeRTOS heap.
Look for configTOTAL_HEAP_SIZE configuration parameter in FreeRTOSConfig.h or corresponding CubeMX setting.
2019-04-19 06:56 AM
Sorry, "the problem" is a super vague/non-specific description.
If it can't allocate a stack look at the heap and related settings that might be limiting/constraining that.
The stack size needs to reflect your expected usage via call tree depth and local/auto variable usage in called subroutines.
2019-04-19 07:43 AM
Ok Thanks Piranha and Clive.