Finished learning how to use an ADC now I'm onto the Hardware PWM of my 17C756A running at 4 Mhz. My set-up is as follows, I have a Pot wired between 0 and 5V wiper going into ADC of PIC, and the result being stored as a variable (B21). I have a LCD displaying the value of the variable correctly ie 0-255. To test the HPWM, I have (in essence) an analogue volt meter connected to the output. I turn my pot up from 0 slowly up to 255 and the output ramps up from 0 to FSD fairly smoothly, but 16 times, 1 after the other, despite the fact that the LCD shows the value of the variable correctly. It does not say in the PBP book that you can use a variable for the Dutycycle, but I tried it and it seems to work, except for the above error. Any help would be much appreciated.

TEST:
HPWM 1, B21, 250 'Output B21 as a voltage
GOSUB LCD
GoTo TEST

LCD:
ADCON0 = %00100001
ADCON1 = %11001010
ADCIN 2, B21 'Read Value of Control Pot.
LCDOUT $FE, 1, "POT"
LCDOut $FE, $14, #B21 'Display Control Pot. value
ADCON1 = %11001110
RETURN