Hi Joe,
I tried your recommendation - couldn't get it to work.
I think it might be something to do with leaving the Pickit2 programmer attached as a 'virtual' serial connnection to my PC - so I moved the AtoD over to AN3 (pin 3)..
This code seems to work...
Many thanks for your help.Code:@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON @MyConfig = MyConfig & _MCLRE_OFF DEFINE OSC 4 ' Internal 8MHz DEFINE ADC_BITS 8 ' 8-bit resolution DEFINE ADC_CLOCK 2 ' Set clock source to Frc/32 DEFINE ADC_SAMPLEUS 50 ' Sample time in uS before A/D conversion is started CMCON0 = 7 'Comparators off ADCON0 = %00000001 'ADC enabled and right justified ANSEL = %00001000 'GPIO.0 and GPIO.1 analog input INTCON = 0 'INTERRUPTS off TRISIO = %111011 'GPIO2 output GPIO = %00010000 ' All outputs = 0 on boot Quanta CON 1251 ' For 10-bit A/D +Vref = 5V : 5V/1023*256=1.251=Quanta ADval VAR WORD ' A/D conversion result DEFINE DEBUG_REG GPIO ' Define DEBUG port DEFINE DEBUG_BIT 0 ' Set GPIO.0 as DEBUG serial output pin DEFINE DEBUG_BAUD 9600 ' DEBUG baud rate = 9600 bps DEFINE DEBUG_MODE 0 ' 1 = inverted, 0 = true MAIN: ADCIN 3, ADval ' Read A/D DEBUG DEC ADvAL,13 ,10 PAUSE 200 GOTO MAIN END




Bookmarks