I gave it a try, could not get it to work correctly
Two 10k resistors as a voltage divider giving a reading of 127 with the serial output on a different pin.
When the serial output is placed on the ADC pin the ADC value drops to 16. The ADC value will change if the divider is changed and the serial still works, just getting incorrect values.
Test code:
Code:
' ADC TEST FOR CHANNEL 2 WITH SERIAL2 OUT
'<FL_PIC12F675>'
'<FL_PBPW>'
DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
CMCON=7
' ANSEL=%00000100
' TRISIO = %000100
RESULT VAR BYTE 'A/D CONVERSION RESULT STORAGE BYTE
START: 'A HEART BEAT
GPIO = %010000:PAUSE 500:GPIO = %000000:PAUSE 500
SEROUT2 GPIO.2, 16780, ["RESULT ",DEC RESULT,$a,$d]
PAUSE 250
GOSUB ADC_2 'STARTS THE READING OF ADC CHANNEL 2
GOTO START
ADC_2: 'READ AN2 GPIO2
PAUSE 100
ANSEL=%00000100
TRISIO = %000100
GPIO = %000100
ADCON0 = %00001001 'TURNS ADC ON
GOSUB READ_AD
RESULT = ADRESH 'PLACES THE ADC VALUE INTO VAR
ANSEL=%00000000
TRISIO = %000000
RETURN
READ_AD: 'DOES THE ADC CONVERSION
PAUSE 50
ADCON0.1=1
WHILE ADCON0.1=1:WEND
RETURN
Bookmarks