Hi c0170, I came across this post and thought it would be a useful way to debug a problem where I think I am running out of task stack space. I added MQX_MONITOR_STACK to my preprocessor settings, and initially everything seemed okay with my device, which is based on the MK22FN256VLL12. However, one of the PWM devices on the board was not working, and after much trial-and-error to determine the cause, I found that with MQX_MONITOR_STACK defined, KSDK 1.2's FTM_DRV_PwmStart() no longer worked.
If I set 100% PWM, the output would be remain low. If I remove MQX_MONITOR_STACK, rebuild, and re-run, the PWM output operates as expected. Have you heard of this happening before?
I have read that all this does is write the "stak" watermark in the remaining stack space. I am not an expert with the RTOS internals nor with assembly, so I can accept with blind faith that what I'm seeing in dispatch.S supports this:
#if MQX_MONITOR_STACK
ASM_LABEL(_fill_stack)
lsrs r1, r1, #2
adds r1, r1, #1 /* Calculate size in _mqx_uints. */
ldr r2, =0x7374616B /* Load pattern "kats". */
b.n _fill_stack_1
ASM_LABEL(_fill_stack_0)
str.w r2, [r0], #4 /* Store pattern to address and increment pointer to next address. */
ASM_LABEL(_fill_stack_1)
subs r1, r1, #1 /* Decrement size counter. */
bne.n _fill_stack_0
#endif /* MQX_MONITOR_STACK */
I've also read that MQX_KERNEL_LOGGING has to be added to enable the _klog* functions, but I have verified that kernel logging is NOT enabled, so I'm having trouble seeing how filling the stack would cause the KSDK PWM function to stop working. Can you please help me to understand how these two things are related?