Hi!
I am trying ADC of 16F684 with this simple code.The problem is that the analog input channels are pulled high.I have tried with different registers but all in vain.
PORTC=0
CMCON0=$07
'CMCON0=$00
ANSEL=$00
TRISC=$00
WPUA=$00 'doesnt effect the output
'OSCCON=%1110111
'configure ADC
ADCON1=%01110000
TRISA.0=1
PORTA=$00
ANSEL.0=1
ADCON0=%00000001
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var word ' Create adval to store result
Res Var word
Define LCD_DREG PORTC
Define LCD_DBIT 0
Define LCD_RSREG PORTC
Define LCD_RSBIT 4
Define LCD_EREG PORTC
Define LCD_EBIT 5
DEFINE LCD_BITS 4
Lcdout $fe,1
loop:
ADCIN 0, adval
Res = 2*adval
Lcdout $fe, $80
Lcdout "T:", DEC2 Res,"C" 'text for the line 1
Pause 300
goto loop
Bookmarks