I am developing for embedded platform using SDK based on FreeRTOS. I need to create a task with xTaskCreate, but I don't completely understand the usStackDepth parameter. The FreeRTOS documentation says:
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. The stack depth multiplied by the stack width must not exceed the maximum value that can be contained in a variable of type size_t.
So, how do I get stack width? Is it platform-dependent? I am targeting 32-bit RISC processor Xtensa lx106
The FreeRTOS task stack width is port dependent. Look in portmacro.h and you should find a definition for portSTACK_TYPE.
If you dig further into tasks.c (remember you have access to the FreeRTOS source code), you'll find that the stack is allocated with the size of ( ( size_t ) usStackDepth ) * sizeof( StackType_t). And then back in portmacro.h you'll find that StackType_t is typedef'd to be the same as portSTACK_TYPE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With