Hi jumper, these are my settings for ADC
define OSC 20
define adc_bits 10 'define number of bits in result
define adc_clock 3 'clock source3=RC
define adc_sampleus 50 'set sampling time in microsec
adc1 var word 'store adc input values, adc1=AN0/RA0
adc2 var word 'AN1/RA1
adc3 var word 'AN2/RA2
adc4 var word 'AN4/RA5
trisa = %11111111 'port A all input
adcon1 = %10000011 '1 for Result Format Selection Bit because using 10 bits
'0011 for AN4, AN2, AN1, AN0 analog port. AN3 is
'Vref+ reference voltage
pause 500 'wait .5 second
Im using the 16F877A. This is my main program and it is supposed to input 4 analog values, do some comparison and then high some ports.
Ive tried a simpler version to test out the port also,
define osc 20
define adc_bits 10 'define number of bits in result
define adc_clock 3 'clock source3=RC
define adc_sampleus 50 'set sampling time in microsec
trisa = %11111111
trisd=0
adcon1 = %10000010
pause 500
adc var word
start:
adcin 0, adc
if adc > 10 then
high portd.0
else
low portd.0
endif
pause 500
goto start
When I input 2.5V into porta.0 the LED does not turn on. If I leave the pin floating (5V) then it turns on. If I change the code to 'adc>0', it turns on.
edit: I think the port A of my PIC is fried. When power is on but nothing is connected, the port A pins are at 5V. Is this normal ? Help pls !
Bookmarks