Referencing the Mister e Calculator, it looks like the best resolution you can get is 0 to 160, where 160 will be 100% Duty Cycle.
Referencing the Mister e Calculator, it looks like the best resolution you can get is 0 to 160, where 160 will be 100% Duty Cycle.
Hi,
That implies one needs to set the Duty Cycle to 80 to get a 4uS On / 4uS Off square wave?
(This does not make sense to me.)
Thanks,
Jay Zebryk
Richard already covered it but it seems to have been overlooked.
The duty cycle register is 10bit wide but, as Ioannis says, the usable number of bits differs depending on the PWM period. The calculator tells you that for 125kHz (with PR2=39) varying the duty cycle register from 0 to 160 will give you a duty cycle of 0-100%.
For 50% duty cycle you obviously want to set the register to 80.
Now, remember that the register is 10bit wide and that two low order bits are in CCP1CON so what goes in CCPR1L is the top 8 bits of the 10bit value. Or, in this case 80/4=20 which, as Richard rightly points out is $14.
your understanding is flawed and math is incorrectIs the Duty Step % (0.625) X 50% = 31.25% the problem?(I am measuring 3.8uS On / 4.2uS Off)
How can I set it for 4mS On / 4mS exactly?
Duty is Steps x 0.625% // steps = CCPR1L x4 + CCP1CON<5:4>
so:
80x0.625% = 50% <=> steps = 20x4 + 0
56x0.625% = 35% <=> steps = 14x4 + 0
Warning I'm not a teacher
Bookmarks