What version of PBP are you using?
I don't have a 685 to test this with, but I ran it through MPSIM using ADCIN, and it appears to work
fine with v2.47. The only difference is instead of setting ADCON1.7 for right justification, you need to
set ADCON0.7. Give this a shot and let me know if it works.
Code:
@ DEVICE PIC16F685,MCLR_OFF,WDT_OFF,INTRC_OSC_NOCLKOUT,PROTECT_OFF
DEFINE ADC_BITS 10
' Set clock source (3=rc)
DEFINE ADC_CLOCK 3
' Set sampling time in microseconds
DEFINE ADC_SAMPLEUS 10
adcVar VAR WORD ' Create variable to store result
Index VAR BYTE ' Loop index for channels
' Set PORTA to all input
TRISA = %00000111 ' AN0 to AN2 inputs
ANSEL = %00000111 ' AN0 to AN2 analog inputs, rest digital
ANSELH = 0 ' AN8 to AN11 digital
' Set up ADCON0 (not ADCON1) like in the manual
ADCON0 = %10000000 ' right justify for 10-bit
Pause 500 ' Wait .5 second
HIGH PORTB.6 ' Turn on status LED
main:
FOR Index = 0 TO 2 ' Display 3 channel results
ADCIN Index,adcVar ' Read AN0 to AN2
GOSUB Display ' Display channel results
NEXT Index
Pause 10 ' Wait.01 second
GoTo main ' Do it forever
Display:
serout portb.7, 6, ["Channel #",#Index,#adcVar]
RETURN
END
You can enable more A/D pins if you need to by setting the ANSEL or ANSELH bits for each port pin
with A/D like shown in the data sheet.
Bookmarks