Switching FTM between PWM and Decoder; Possible SDK bug?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Switching FTM between PWM and Decoder; Possible SDK bug?

474 Views
andy1
Contributor II

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.

Labels (1)
Tags (2)
0 Kudos
1 Reply

411 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Andrew Smolak,

I can see the QUADEN is cleared in FTM_SetupInputCapture and FTM_SetupOutputCompare but no in the non-decoder setup functions (ie. FTM_SetupPwm).

FTM_SetupInputCapture QUADEN.png

FTM_SetupOutputCompare QUADEN.png
I will report it to MCUXpresso SDK team.
Thank you for reporting this.  
Have a great day!

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos