I can't tell you if your chip behaves the same as mine, but I use a lot of 18F2321's and I found that ADCIN didn't work.
Try this.
Code:ADCON0 = %00000001 ; Turn it on ADCON1 = %00010011 ; Chan 0 -11, Vref, GND (note that I use a precision reference on AN3) ADCON2 = %10001001 ; Rt jus, 2Tad, /8 clk Main: Chan = 4 ;Pick the channel you want to read NumSamples = 10 ; Do multiple reads for averaging or scaling Gosub DOADC ; resut is in ADCSTOR (WORD) GoTo Main ..... DOADC: ADCSTOR = 0 For X = 1 to NumSamples ADCON0 = ((Chan << 2) | %00000011) While ADCON0.1:WEND ADCVAR.highbyte = ADRESH ADCVAR.lowbyte = ADRESL ADCSTOR = ADCSTOR + ADCVAR Pauseus 20 Next X Return




Bookmarks