Got it working. Heres the code:
DEFINE FOSC 100
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
OSCCON = %01100001 '4 Mhz
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify
output portc.5
adcVar VAR word
dutyCycle var byte
main:
ADCIN 0, adcVar
dutyCycle = adcVar/256
hpwm 1,dutyCycle,6000
goto main
Bookmarks