Hi,
With 16MHz main clock there are three different prescaler ratios all giving you 250kHz but different number of bits of resolution.
If you set prescaler to 1:2 and load PR2 with 3 then you'll get 250kHz and 5 bits of resolution (not 5 "full" bits actually), ie you can set the dutycycle value anywhere between 0 and 16.
If you set the prescaler to 1:1 and load PR2 with 15 you'll get the same frequency but now you've got better resolution, 0-64 instead of 0-16.
Now, just write out whatever value you want in binary as a 10bit value: %0000010110
The two least significant bits goes to CCP1CON.5 and CCP1CON.4 and the remaining 8 bits goes to CCPR1L, in this case (as in your example) the result would be 21 which would result in either 100% or ~20% depending on the prescaler and PR2 setting as outlined above.
/Henrik.
Bookmarks