Well, I must be missing something obvious in the docs. I can't get the ADC stuff working on my PIC18F2455. The simulator steps through it, but the micro doesn't seem to read anything.
Oh, yeah, what clock speed am I setting in the config section? The code that does run seems slower than it did on the learning devices.
Thanks for any hints, advice, pointers, etc.
Here's the relevant portions of the code:
;setup/initialization #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 ; need lots of a/d inputs config LPT1OSC = OFF config FOSC = INTOSCIO_EC
BSF ADCON2,5 ; set Tad = 8 BSF ADCON2,2 ; Fosc/4
MOVLW 0x03 MOVWF ADCON1 ; set vrefs (internal), AN0-AN11 on
ADCREAD MOVWF ADCON0 ; set A/D to channel defined in WREG CALL ONE_US CALL ONE_US CALL ONE_US ; wait 5us for A/D to settle CALL ONE_US CALL ONE_US BSF ADCON0,0 ; start conversion BTFSC ADCON0,1 ; this bit will change to zero when the conversion is complete goto $-2 BCF ADCON0,0 ; turn off A/D RETURN
; in the main program MOVLW 0x00 ; tell ADC to read AN0 CALL ADCREAD