I don't really care for the HPWM command. I think it's easier to manually set the registers. This is a conversion from part of my code that may work for you to at least get the PWM working.
This is for an 8MHz oscillator (on a 18F2525, so double check register names):
T2CON = 4 'Timer2 = ON; Prescale = 1:1
PR2 = 200 '(period) this should give you should give you about 10KHz
CCPR1L = 100 '(duty cycle) 100 should be close to 50%, 20 is about 10%, etc
To turn PWM ON:
CCP1CON = 12
To turn PWM OFF:
CCP1CON = 0
Bookmarks