I just tested the program above to test the HPWM command, in reality I want to use the following:

Mainloop:
ADCON0.2 = 1 'Start Conversion
ADCIN 1, DutyCycle 'analog pin 1 get the 8 bit result
HPWM 1,DutyCycle,10800
GOTO Mainloop
end

but even with
HPWM 1,166,10800
I am not getting the right duty cycle.

Do I need to define HPWM1_TIMER?

k