Hi there,
I'm trying to make ADC on the PICKit2 low pin count demo board, it has a pot on AN0 and 4 LEDs on PORTC here is the code I'm trying it just lights an LED on pin 5 of PORTC and keeps it alight. Don't know what's the problem
I'm trying to make ADC on the PICKit2 low pin count demo board, it has a pot on AN0 and 4 LEDs on PORTC here is the code I'm trying it just lights an LED on pin 5 of PORTC and keeps it alight. Don't know what's the problem
HTML:
List p=16f690
#include<p16f690.inc>
__CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
ERRORLEVEL - 302
;**********************************************************************
bsf STATUS,RP0
bsf TRISA,TRISA0
clrf TRISB
clrf TRISC
bcf STATUS,RP0
;**********************************************************************
main:
nop
nop
nop
nop
nop
nop ; Delay for capacitor to discharge
banksel ADCON0
btfss ADCON0,0x01
goto Loop1
banksel ANSEL
bsf ANSEL,ANS0
banksel ADCON0
movlw b'00000001' ; ADFM = 0 (left justified so just read ADRESH and no ADRESL), VCFG = 1 = VDD, CHS = AN0, GO/DONE = 0,ADON = 1
movwf ADCON0
bsf ADCON0,0x01 ; start ADC
banksel ADCON1
movlw b'001'
movwf ADCON1
banksel PIR1
btfsc PIR1,ADIF
goto Loop1
goto main
Loop1:
banksel ADRESH
movf ADRESH,w
movwf PORTC
banksel PIR1
bcf PIR1, ADIF
retlw 00h
end