Stack usage in a task

What is the best way to determine how many stack I need to assign to a task?

Stack usage in a task

Well you could try calculating it [max function call depth + plus max interrupt nesting depth + etc] but really trial and error is the best way. Start at [configMINIMAL_STACK_SIZE * 2], let the task run for a bit, then inspect the high water mark using http://www.freertos.org/uxTaskGetStackHighWaterMark.html and adjust as fit. If the task does not get that far use http://www.freertos.org/Stacks-and-stack-overflow-checking.html to trap errors. The new MPLAB and Eclipse plugins make this easier as they display the high water mark.

Stack usage in a task

Ah, didn’t know that kind of (powerfull) tools. How about the plugin? I have the latest version (not beta) of MPlab.

Stack usage in a task

*just curious, how big is the minimal_stack_size ? I mean, how many stacks can it contain?

Stack usage in a task

It is sized so the idle task can run without crashing, but how big that has to be depends on the architecture. The idle task does not do anything so only requires a small stack.