Hi,
I really hope you've learned something here....How much time have you (and I) wasted on that simulator by now? If you had put a PIC on a breadboard from the get go you'd be done by now.
As you know by now the PWM period ends when TMR2=PR2. So if you set the CCPR1L value to whatever you have PR2 set to you'll get 100% dutycycle (this assumes 1:1 prescaler). So, if PR2 is 200 then setting CCPR1L to 200 will give you 100% dutycycle, setting it to 50 will give you 25% dutycycle and so on. The two lowest significant bits (CCP1CON<5:4>) adds 2 bits (or 4 times if you will ) worth of resolution. So if you prefer you could say that a DutyVal of PR2*4=100%.
For example, DutyVal=800. Take the 2 low bits and stuff them CCP1CON5:4 and take the 8 high bits in stuff them in CCPR1L. If you take a close look at the 8 bits alone you'll see that it's the value 200.
/Henrik.
Bookmarks