Hi,
I want to generate PWM in FTM 2 Channel 1 pin PTH1 using output compare mode. Please help me in setting the duty cycle, frequency etc.
I have made the code snippet below which generates a PWM from the pin but don't know how to control it.
Solved! Go to Solution.
Hi VIGNESH bALAJI,
If you want to change the duty cycle and the frequency, I suggest you use the EPWM mode instead of the the output compare mode.
Because from your code, you are using the output compare mode with match toggles the channel output, then the duty will be fixed at the the 50%, but if you want to change the frequency , you can change the MOD register.
But, if you use the EPWM, if you want to change the duty, you can change the CnV value; if you want to change the frequency, you can change the MOD register.
You can try it on your side.
About the code, you can refer to the KE FTM project, which can be downloaded from this link:
https://www.nxp.com/webapp/Download?colCode=FRDM-KEXX-Driver-Library-Package&appType=license
If you still have question about it, please kindly let me know.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi VIGNESH bALAJI,
If you want to change the duty cycle and the frequency, I suggest you use the EPWM mode instead of the the output compare mode.
Because from your code, you are using the output compare mode with match toggles the channel output, then the duty will be fixed at the the 50%, but if you want to change the frequency , you can change the MOD register.
But, if you use the EPWM, if you want to change the duty, you can change the CnV value; if you want to change the frequency, you can change the MOD register.
You can try it on your side.
About the code, you can refer to the KE FTM project, which can be downloaded from this link:
https://www.nxp.com/webapp/Download?colCode=FRDM-KEXX-Driver-Library-Package&appType=license
If you still have question about it, please kindly let me know.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you Kerry Zhou,
I figured out the same thing yesterday and it worked for me :smileyhappy:. Thanks for conforming it.