This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMDX570LC43HDK: FreeRTOS problems with usStackDepth for task creation

Part Number: TMDX570LC43HDK

Hy,

I'm developing a project using freertos on TMDX570LC43HDK,

it happens that some task starts to work just choosing a big enough usStackDepth

 * @param usStackDepth The size of the task stack specified as the number of
 * variables the stack can hold - not the number of bytes.  For example, if
 * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
 * will be allocated for stack storage.

changing from example from 128 to 128*10

but in this way just with 2 task 128*10 there are problems creating the second task,

I know code optimization could be a solution, but what else?

It is related also to this config -->  #define configTOTAL_HEAP_SIZE          ( ( size_t ) 8192 )

maybe reducing the heap size I could have more space for stack? The available space for heap and stack on TMDX570LC43HDK is 512kB

Antonio

  • Hello Antonio,

    In freeRTOS, each task has it's own stack, and the stack size is usStackDepth*4 bytes (32-bit device). So your stack size for each task is 128*10*4=5KB.

    The stacks for the tasks come from the "FreeRTOS heap". Task context is saved into this space. configTOTAL_HEAP_SIZE in FreeRTOSConfig.h reserves the total space for for tasks, queues, semaphores, etc. When the task is created, it allocates a task control block from this total space. So increasing the heap size may be a solution too.
  • ok, thanks,
    I was in doubt due to stack vs heap relationship, but I will try increasing the heap size,
    thanks
    Antonio