PWM Duty Cycle

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am trying to change the duty cycle of signal. if I set higher period for PWM component, i can acheive the duty cycle whereas I am not geeting the exact frequency. 

   

I am using Timer(tc) to input the PWM. 

   

How can I acheive the duty as well as correct frequency?

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Use a PWM component and a clock. Set the period value so, that Clock / Period = desired frequency.

   

Now you may set in your program the compare-value with the appropiate API between 0 (0%) and the period value (100%).

   

This will keep the frequency of the PWM stable and only changes the duty-cycle.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Note the update of the compare register is async, so you can short cycle

   

the current period duty cycle being output by PWM. To avoid this use an ISR on

   

the Tc output to do the update of compare register. Note this is not true for the

   

period register, it is updated at end of period with an internal reload of period register.

   

 

   

   

 

   

 

   

   

 

   

Regards, Dana.

0 Likes