FRDM-KW41Z

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

FRDM-KW41Z

跳至解决方案
1,426 次查看
surender1896
Contributor I

Can anyone suggest me a code for sensing ADC and giving to PWM channels, I'm having an problem regarding this

标签 (1)
0 项奖励
回复
1 解答
1,361 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi  surender elumalai,

Seems that you want to update PWM duty cycle according to the ADC value.
You don't need to initialize pwm(pwm_init) every time, The pwm_init only need to run one time in main function.
What you need to do is just update the duty cycle in ADC16_SE4_IRQ_HANDLER_FUNC.
TPM_UpdatePwmDutycycle can be use to achieve it.

For example:
TPM_UpdatePwmDutycycle(BOARD_TPM_BASEADDR, BOARD_TPM_CHANNEL_PAIR, kTPM_CombinedPwm, updatedDutycycle);

Best Regards,

Robin

 

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

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,361 次查看
surender1896
Contributor I

Thank you for your answer

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

Hi  surender elumalai,

Seems that you want to update PWM duty cycle according to the ADC value.
You don't need to initialize pwm(pwm_init) every time, The pwm_init only need to run one time in main function.
What you need to do is just update the duty cycle in ADC16_SE4_IRQ_HANDLER_FUNC.
TPM_UpdatePwmDutycycle can be use to achieve it.

For example:
TPM_UpdatePwmDutycycle(BOARD_TPM_BASEADDR, BOARD_TPM_CHANNEL_PAIR, kTPM_CombinedPwm, updatedDutycycle);

Best Regards,

Robin

 

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

0 项奖励
回复