I have a beginner question about the memory size of tasks.
First, when I create a task with xTaskCreate, I don’t understand how to size the task stack. usStackDepth must be defined as the number of variables in the task. It’s not easy to determine the number of variables in my tasks because I have created a large number of variables. Moreover, the stack storage is calculated with usStackDepth (number of variables) * stack wide (bits). How can I set the stack wide? Is it always 4 because I use a 32-bit microcontroler?
My second question is about uxTaskGetStackHighWaterMark(NULL) which must return the remaining free space memory in the stack. When I use this instruction in the task, it returns me always a number very close to the usStackDepth defined for the task. For example, if my task is created with usStackDepth = 2048, the return value of uxTaskGetStackHighWaterMark is around 1928, thus 120*4 = 480 bytes of used memory space. I’m right?
Thanks for your help!