Configuring the Stack

In FreeRTOS, each task has its own, separate stack. The task stacks are allocated on the heap when using dynamic memory allocation. Except for the idle task, the stacks are allocated when calling xTaskCreate(), where one of the input parameters is the stack size for the task.

The idle task is created when calling vTaskStartScheduler() to ensure that there is always at least one task that is able to run. The idle task's stack size is given by configMINIMAL_STACK_SIZE in the configuration file.

It is important that the sum of allocated stack memory, as well as allocated memory from queues, semaphores, etc., does not exceed the heap size defined in configTOTAL_HEAP_SIZE.