Quote Originally Posted by HenrikOlsson View Post
Hi Hank,
Usually it's done like this:
Code:
CCP2CON.4 = Duty.0       'Bit 0
CCP2CON.5 = Duty.1       'Bit 1
CCPR2L = Duty >> 2        'Bit 2-7
Now, the resolution you'll actually get depends on the frequency you're using as well as the prescaler ratio. You MAY end up with 9 or 10 bits resolution in which case you must scale up "your" 8 bit dutycycle value to match the resolution of the hardware. Otherwise you might not be able to "swing" the dutycyle all the way to 100% - if that's what you need.

Have you checkes out Darrels MIBAM routine? Never played with myself but it's supposed to do wonders for multiple fading LEDs.

/Henrik.
Many thanks Henrik........Deep down I knew the answer would be splendidly (embarrasingly!) simple - thanks for the lightning response.

Sigh, as one case closes another opens.... I'm running a 16f1824 @4mhz oscillator, and I need the frequency of the PWM to be inaudible (therefore say about 20khz+) ....how can I be sure that my resolution remains at 8 bits.

No, I was not aware of Darrels MIBAM routine....I'll seek it out.