PDA

View Full Version : PIC16F690 ADC question



matador29b
- 21st October 2009, 22:49
I have been trying to use the onboard ADC, and it works, butt when trying on the RPB4 (AN10), it does not respond, am I missing something?:confused:

mackrackit
- 22nd October 2009, 01:51
Can we see your code?

matador29b
- 23rd October 2009, 23:03
DEFINE OSC 8
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 20 ' Set sampling time in uS


TRISA = %00000000
TRISB =%11111111
TRISC = %00000000

ANSEL = %00000000
ANSELH = %00000100
ADCON0 = %00101000
ADCON1 = %00100000


vinput var PORTB.4
B0 var byte
B1 var byte


clear

inicio:
call cal_pot
pause 500
goto inicio

cal_pot:
adcin vinput,B0
serout PORTA.0, 0 ,["ADCIN = ",#B1,10,13]

return

The same code works for any pin in port A (I have not tried B or C), obviously changing the appropriate ANSEL and ADCON.

Nothing else changes, other than the jumper to the pin. I thought maybe the pin was blown, but different chips yielded the same result.
Thanks