Hi

My current project uses an 18F4520 with two hardware PWM pins (C1 and C2) to drive two LED drivers so that the chains of LEDs can be ramped up and down. My code also uses an internal timer overflow to generate the clock so using software with pause statements is out of the question.

I've been doing some research to try and find a PIC that can provide more hardware PWM outputs and stumbled across the 18F4331 which seems to have dedicated 4 independent PWM outputs, which is primary used for motor control. I've looked at the datasheet but can not comprehend the information so wondered if one of you guys who understand these sheets can offer some advice. The data sheet can be found here http://ww1.microchip.com/downloads/e...Doc/39616d.pdf

Basically I need four independent PWM outputs where the duty cycle changes for each output (the frequency can be the same for each channel.

Currently I use the
Code:
    hpwm 1,W_PWM,200        
    hpwm 2,B_PWM,200
Where W_PWM is the duty cycle to fade up the white LEDs and B_PWM the blues. This currently used the two CCP1 and CCP2 registers. Ideally I would like to have something like HPWM 3, and 4 in the code.

Would this work, or can the 18F4520 CCP registers be configured to give two more additional PWM outputs as the data sheet states the 18F4520 has "One, two or four PWM outputs". Again I'm assuming that four outputs are used for motor control where the duty cycle is identical for each output rather than being independent.

My settings for CCP registers are
Code:
CCP1CON = %00001100                     'Set CCP1 to PWM 
CCP2CON = %00001100                     'Set CCP2 to PWM
I'd rather not post up my full code in the forum, but will send it via PM if required.

Any help would be most appreciated

Malcolm