FRDM-KW41Z

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

FRDM-KW41Z

Jump to solution
458 Views
surender1896
Contributor I

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

Labels (1)
0 Kudos
1 Solution
393 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
393 Views
surender1896
Contributor I

Thank you for your answer

0 Kudos
394 Views
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 Kudos