Hi !
I try to understand how work communication between PIC and PC.
I wrote this simple code :
Code:
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
INCLUDE "modedefs.bas"
DEFINE OSC 04
CMCON = 7
VRCON = 0
WPU = 0 'no wake pullup
IOCB = 0 'no int. on change
ANSEL = %01010001
ADCON0 = %10000001 'right just , Vref=Vdd , ch.0 , A/D on
GPIO = %00101001 'preset I/O
TRISIO = %00001001 'configure direction 1=input 0=output
OPTION_REG = %10000111
advalue var word
Main:
PauseUs 50 'sample time
ADCON0.1 = 1 'start A/D
@ nop
while ADCON0.1 = 1
wend
advalue.byte1 = ADRESH 'get A/D value
advalue.byte0 = ADRESL
if advalue < 650 then
SerOut2 GPIO.5,300,["Advalue : ",DEC advalue, 13, 10] ; the calculated result is "93" , but ?!
endif
goto Main
I use on GPIO.0 one 1k resistor to +5 volts and one 100R resistor to ground. Advalue is 93, don't ?!
But on RealTerm I am unable to see the "real" value of Advalue, no matter what option I choose...
What I do wrong ?!
Thanks in advance !
Bookmarks