Hi,
I want to change the duty cycle of an PWM frequenctly as per my requirement.
Can you tell me how to do it and also tell me the how to calculate the duty cycle based on input clk frequency
Thanks in advance
Solved! Go to Solution.
The PWM duty cycle is independent of the input frequency.
Duty Cycle in % = 100 * Period / Compare value
Both values can be changed by APIs, see the PWM datasheet.
Bob
The PWM duty cycle is independent of the input frequency.
Duty Cycle in % = 100 * Period / Compare value
Both values can be changed by APIs, see the PWM datasheet.
Bob
Thanks Bob for reply
hI,
i want to generate a pwm dutycycle 20% to 90% but these below apis
PWM_WritePeriod(3);
PWM_WriteCompare(10);
given the same waveform output that is it's not working.
according to your formula Duty Cycle in % = 100 * Period / Compare value
but it's not working.
Please help me to resolve the issue.
Thnbaks in advance.
in my code i removed the while(1); it's not working
Thanks sir
Hi
It is better to use the PWM block with higher counts(high period value) for higher accuracy. Other wise one clock cycle for toggle state can introduce this much error.