I don't know how to "prove" that there is a potential bug with MQX_MONITOR_STACK except to describe my test case.
I have a MK22FN256VLL12 that drives 2 H-bridges via the MK22's PWM output. I am using the PWM function FTM_DRV_PwmStart() in the KSDK.
Regardless of what I set for the PWM duty cycle, the PWM output of the MK22 is just logic low, only when I have MQX_MONITOR_STACK in my preprocessor settings. If I remove it, the PWM driver works as expected.
I have read that all this does is write the "stak" watermark in the remaining stack space, and it looks like this is done here in dispatch.S:
- #if MQX_MONITOR_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
- str.w r2, [r0], #4 /* Store pattern to address and increment pointer to next address. */
- 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.
Has anyone else here experienced this? Can anyone at FSL test out what I am describing to see if you can reproduce it? It is reproducible on all of our PCBs.