I am not fully understanding the setup for the ADC, and therefor, I am missing something. With the following code I get my readout on the LCD, but I get 0 99.9% of the pot travel, and 255 @ POT WOT. Anyone see my problem?
Code:
#CONFIG
__config _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_LO & _LVP_OFF
#ENDCONFIG
DEFINE OSC 20
Define ADC_BITS 8
Define ADC_CLOCK 3
Define ADC_SAMPLEUS 50
Define LCD_DREG PORTC
Define LCD_DBIT 0
Define LCD_RSREG PORTB
Define LCD_RSBIT 4
Define LCD_EREG PORTC
Define LCD_EBIT 6
TRISA = %11111111
ADCON1 = %00000100
adval1 var word
adval2 var word
ADCON0 = 0
ANSELA = 1
ANSELB = 0
ANSELC = 0
adval1 = 0
Temp:
adcin 0, adval1
Lcdout $fe, 1
Lcdout "Value: ", DEC adval1 ' Display the decimal value
Pause 100
goto temp
Bookmarks