Hi All
Not used this PIC before, trying to read a voltage on AN0 pin17 but get the same result on my serial out for any input, 5235. I suspect I`ve either miss configured a register or missed one altogether. My test code is as follows, anything obvious?. Running 8mHz, a LED flashes OK at correct intervals as far as I can tell.
Cheers Pete
CODE:
#CONFIG
__config _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _MCLR_ON & _BODEN_ON & _LVP_OFF & _WRT_ENABLE_1536 & _DEBUG_OFF & _CP_ALL
#ENDCONFIG
'Set PIC register defaults
OPTION_REG.7=0 ' enable pull-ups on port B
OSCCON = %01110000 ' Internal 8 MHz osc
TRISA = %00000011 'set RA0/1 to inputs, all others to outputs
TRISB = %00001111 'out,out,out,out,in,in,in,in
ADCON1 = %11001110 'Use RA0 for Analogue input Right Justified
DEFINE OSC 8
'Define ADCIN Parameters
Define ADC_BITS 10
Define ADC_CLOCK 1
Define ADC_SAMPLEUS 50
'PortA.2 is serial debug
extdataOut var porta.2
'Define variables
InputVoltage var word
test:
ADCIN 0,InputVoltage 'Get value
serout2 extdataOut,16468,["Debug ",dec4 InputVoltage,13]
pause 1000
goto test
Bookmarks