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.




Bookmarks