AnsweredAssumed Answered

Switching FTM between PWM and Decoder; Possible SDK bug?

Question asked by Andrew Smolak on Jun 7, 2019
Latest reply on Jun 11, 2019 by Robin_Shen

My application (for MK22FN512) requires sharing one of the FTMs between a PWM output and an Encoder. I had a hell of a time getting it to work using the SDK. (Using the functions in fsl_ftm.c)

 

After poking around a few hours I realized that once the FTM was switched into decoder mode, it would basically get "stuck" there. The PWM would never start counting again, even using the exact same code that works when called out of reset. It turns out that the QUADEN bit in QDCTRL does not get cleared.

 

These two lines solved my problem:

LED_PWM_FTM_BASEADDR->MODE |= FTM_MODE_WPDIS_MASK;
LED_PWM_FTM_BASEADDR->QDCTRL &= ~FTM_QDCTRL_QUADEN_MASK;

 

It seems to me that the SDK should clear this bit in FTM_Deinit or in the non-decoder setup functions (ie. FTM_SetupPwm).

 

I wasn't sure where to file a bug report, but figured this might help anyone that might run into the same problem.

Outcomes