Switching FTM between PWM and Decoder; Possible SDK bug?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Switching FTM between PWM and Decoder; Possible SDK bug?

995 次查看
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.

标签 (1)
标记 (2)
0 项奖励
回复
1 回复

932 次查看
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 项奖励
回复