16F1827 code below will allow only 2 of the available 4 PWM channels to run simultaneously. Need 3 Simultaneous PWM channels, all at different frequencies.

Channel 1 & 3 will work provided channel 4 is not enabled.
Channel 2 won't run ever.
Channel 3 always works.
Channel 3 & 4 will work but breaks channel 1.

Compiler is PBPX 3.0.1.4

Sorry couldn't figure out how to wrap "code tags" around the code block.

Can anyone spot what I'm doing wrong?


'************************************************* ******************************
'
DEFINE OSC 4 'inform compiler of "intended" oscillator freq
'
OSCCON = %01101010 '4Mhz internal (%01110000 for 8Mhz)
DACCON0 = %11100000 'DAC config reg
DACCON1 = %00000000 '
ANSELA = %00000000 'All digital. A/D disabled
ANSELB = %00000000
APFCON1 = %00000001 'Alternate pin function config
FVRCON = %00000000
ADCON0 = %00000001
ADCON1 = %10010000
INTCON = %00000000
'
APFCON0 = %00001000 'CCP1=RB3,CCP2=RA7 (CCP3=RA3, CCP4=RA4)
CCPTMRS = %00100100 'CCP1=TMR2,CCP2=TMR4,CCP3=TMR6 in PWM Mode
'
pr2 = 77 '400Hz
t2con = 32
pr4 = 68 '900Hz
t4con = 16
pr6 = 77 '1600Hz
t6con = 8
'
TRISA = %00100001 '
TRISB = %11000010
'
'************************************************* ******************************
'
' HPWM configs
'
'************************************************* ******************************
'
DEFINE CCP1_REG PORTB
DEFINE CCP1_BIT 3 'pin 9
DEFINE CCP2_REG PORTA '
DEFINE CCP2_BIT 7 'pin 16
DEFINE CCP3_REG PORTA '
DEFINE CCP3_BIT 3 'pin 2
DEFINE CCP4_REG PORTA '
DEFINE CCP4_BIT 4 'pin 3
'
HPWM 1,127,400 'works if CCP4 not enabled
HPWM 2,127,1600 'CCP2 doesn't work at all
HPWM 3,127,900 'works always
'HPWM 4,127,1000 'CCP4 works but breaks CCP1
STOP
'
end