Hello all,

I'm trying to get PWM6 and PWM7 working on the 16F18857, and unfortunately these two are not accessible with the HPWM command. I've got them set to 50% duty cycle and I believe set to operate on the same timer (TIMER2) as the CCP HPWM peripherals, yet I get NADA when I look at the outputs. All the HPWM outputs (CCP 1-5) work as anticipated.

It's not critical that the first timing period is accurate, so sloppy entry without an interrupt enabling at the end of a timing cycle period is fine.

Any suggestions on what I've missed here?

Thanks in advance for any brilliant ideas...



'Using PIC16F18857

DEFINE OSC 8 '8MHz
OSCFRQ=$03

TRISA=0 'all outputs
ANSELA=0 '1=Analog, 0=Digital
TRISB=0 'all outputs
ANSELB=0 'all Digital
TRISC=0 'all outputs
ANSELC=0 'all Digital

'PPS MODULE (Peripheral Pin Select)
RA2PPS=$0E 'PWM6OUT OUTPUT on RA2
RA3PPS=$0F 'PWM7OUT OUTPUT on RA3

' *** HPWM format as follows:
'HPWM Channel, Dutycycle, Frequency

HPWM 1, 0, 1000 '51/255 or 0% duty cycle pin 13
HPWM 2, 102, 1000 '110/255 or 40% duty cycle pin 12
HPWM 3, 153, 1000 '153/255 or 60% duty cycle pin 26
HPWM 4, 204, 1000 '204/255 or 80% duty cycle pin 21
HPWM 5, 127, 1000 '240/255 or 50% duty cycle pin 6

' Now, we need to select the same timer for PWM6 and 7 that is used for CCP1 (TMR2)
CCPTMRS1=%00010101

PWM6CON=%10010000 'enable and active high
PWM7CON=%10010000 'enable and active high

'set at 50% for both to test
PWM6DCH=128:PWM6DCL=0 'PORTA.2 (pin 4)
PWM7DCH=128:PWM7DCL=0 'PORTA.3 (pin 5)

keepgoing:
pause 500
goto keepgoing

end