Monitoring for stack and heap problems
When many people first start programming with an RTOS, one of the immediate challenges is figuring out how to properly size the stack for each task. This can lead to some frustration during development because when a stack is overrun, the symptoms can range from odd behavior to a full system crash.
Keeping an eye on stack space
FreeRTOS provides the option for using a stack-overflow callback function. The function is named vApplicationStackOverflowHook. If you choose to use it, it may save you from experiencing the oddball behavior or failure of an application that overruns its stack. When configCHECK_FOR_STACK_OVERFLOW is enabled in FreeRTOSConfig.h, any time a stack overflow is detected by FreeRTOS, the callback function will be run.
There are two potential values for configCHECK_FOR_STACK_OVERFLOW:
#define configCHECK_FOR_STACK_OVERFLOW 1: Checks the stack-pointer location upon task exit.#define configCHECK_FOR_STACK_OVERFLOW...