Here is my initialization code for 16F1826 . I want RA5 to act as an INPUT. However, when I check PortA.5 no matter if it is HI or LO, it does not seem to function as an INPUT.
I have a 100k ohm resistor to +5VDC from pin4. I simply short the pin to GND to simulate the port as LO.
Code:
#CONFIG
__config _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _STVREN_OFF
#ENDCONFIG
'_MCLRE_OFF = MCLR pin functions as INPUT RA5, MCLR internally tied to VDD
DEFINE OSC 4
DEFINE ADC_BITS 10 ' 10 bit A/D Conversion
DEFINE ADC_CLOCK 4 ' 4MHz Clock
DEFINE ADC_SAMPLEUS 50 ' 50 uS A/D sample time
TRISA = %00101100 ' Set RA2, RA3 and RA5 as Inputs
TRISB = %00000000 ' All PortB as Output
'ADC Setup
ADCON1 =%11000000 ' Right justified
ANSELA =%00000010 ' AN2 on PortA.2 Analog
ANSELB =%00000000 ' Digital inputs
adval var word
mainloop:
if PortA.5= 1 then PortB.1 = 1 'turn ON an LED
if PortA.5= 0 then PortB.1= 0 'turn OFF an LED
goto mainloop
I do not get it. Help! Thanks!
Bookmarks