Why does FTM_UpdatePwmDutycycle work but directly setting FTM2_C1V do nothing?

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

Why does FTM_UpdatePwmDutycycle work but directly setting FTM2_C1V do nothing?

跳至解决方案
1,092 次查看
pcpro178
Contributor III

I'm developing an application wherein we need finer granularity on the PWM output than a strict duty cycle (0-100) will give us.  I've run into a snag wherein directly setting the FTM2_C1V register seems to do nothing.  Calling `FTM_UpdatePwmDutycycle` followed by `FTM_SetSoftwareTrigger` works fine.  When I inspect these functions it appears that all `FTM_UpdatePwmDutycycle` basically does is set the value of FTMx_CnV, and `FTM_SetSoftwareTrigger` sets SYNC.  If I directly set FTM2_C1V in my code and then make the same call `FTM_SetSoftwareTrigger` nothing happens.  Why?  What do I need to do to get this working? 

Works:

FTM_UpdatePwmDutycycle(FTM2, (ftm_chnl_t)1, kFTM_EdgeAlignedPwm, dutyCycle);
FTM_SetSoftwareTrigger(FTM2, true);

Does not work:

FTM2->CONTROLS[1].CnV = (uint32_t)cnt;
FTM_SetSoftwareTrigger(FTM2, true);

My FTM initialization follows the example in ftm_pwm_twochannel.c

标签 (1)
标记 (3)
0 项奖励
回复
1 解答
871 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Jim Fell,

I can get it work on FRDM-K64F board, PWM waveform will change on PTB18 and PTB19 pins.
You can download the attached files and test it on FRDM-K64F board.

ftm_pwm_twochannel.png

 

Best Regards,

Robin

 

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

在原帖中查看解决方案

0 项奖励
回复
1 回复
872 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Jim Fell,

I can get it work on FRDM-K64F board, PWM waveform will change on PTB18 and PTB19 pins.
You can download the attached files and test it on FRDM-K64F board.

ftm_pwm_twochannel.png

 

Best Regards,

Robin

 

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

0 项奖励
回复