I can't get the A/D inputs to work. What blindingly-obvious thing am I missing?
#include config LVP = OFF config XINST = OFF config CPUDIV = OSC1_PLL2 config PLLDIV = 1 config WDT = OFF config MCLRE = OFF config DEBUG = OFF config PBADEN = ON config LPT1OSC = OFF config FOSC = INTOSCIO_EC
org 0 ;============================= ; Set up I/O ports ;============================= MOVLW 0x2F ; make A0-A3,A5 analog in; A4, A6 digital out, MOVWF TRISA MOVLW 0x1E ; make B1-B4 analog in, B0,B5-B7 digital out, MOVWF TRISB CLRF TRISC ; Make PortC digital out
;====================================== ; register, A/D initialization ;====================================== CLRF PORTA CLRF PORTB CLRF PORTC
BSF ADCON2,7 ; right justify BSF ADCON2,4 ; set Tad = 32 BSF ADCON2,2 ; Fosc/4
MOVLW 0x03 MOVWF ADCON1 ; set inputs AN0-AN10, vrefs Vdd/Vss
goto start
ADCREAD MOVWF ADCON0 ; set A/D to channel defined in WREG BSF ADCON0,0 ; start conversion CALL ONE_US CALL ONE_US CALL ONE_US ; wait 5us for A/D to settle CALL ONE_US CALL ONE_US BSF ADCON0,1 ; set the GO bit BTFSC ADCON0,1 ; GO bit will change to zero when the conversion is complete goto $-2
MOVFF ADRESH, TEMPHI MOVFF ADRESL, TEMPLO
BCF ADCON0,0 ; turn off A/D RETURN
START MOVLW 0x00 ; set ADC to read AN0 CALL ADCREAD END