Something like this might help so it doesn't drop-off the end and restart from the beginning. It also loads the new duty-cycle values.
Code:
PTCON1=%10000000
OVDCOND = %00000010 'PWM on PWM1
Main:
ADCON0.1 = 1 ' Start the conversion
While ADCON0.1=1 ' Wait for it to complete
Wend
Duty.HighByte = ADRESH ' get result from AN0
Duty.LowByte = ADRESL ' Increment buffer pointer
PDC0L = Duty.LowByte
PDC0H = Duty.HighByte
PDC1L = Duty.LowByte
PDC1H = Duty.HighByte
PDC2L = Duty.LowByte
PDC2H = Duty.HighByte
GoTo Main
It's untested, but should work. I didn't check the A/D part, but it looks ok at a glance.
You might want to insert a PAUSE before the GOTO Main?
Bookmarks