Hi,
When I write _MCLRE_OFF in the config FUSES to make RA5 as a normal input, RA1 goes high! And when i turn it on again RA1 goes low! This is a problem since i've got a switch connetcted to ra5 and when i press it, RA1 should go high. But it goes high even when RA5 input reads "0".
I use a PIC16F628A btw.
Thanks.
Here is the code. Couldent find anything wrong. Maby you can
When I write _MCLRE_OFF in the config FUSES to make RA5 as a normal input, RA1 goes high! And when i turn it on again RA1 goes low! This is a problem since i've got a switch connetcted to ra5 and when i press it, RA1 should go high. But it goes high even when RA5 input reads "0".
I use a PIC16F628A btw.
Thanks.
Here is the code. Couldent find anything wrong. Maby you can
Code:
list p=16F628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT
cblock 0x20
d1
d2
d3
endc
org 0x0000
movlw 0x07 ;Turn Off comp
movwf CMCON
clrf PORTA
clrf PORTB
banksel TRISA ;Port definitions
movlw b'11110001'
movwf TRISA
movlw 0x00
movwf TRISB
Banksel PORTA
;main----------------------------
start ;Switch interactions
movlw b'00001111'
movwf PORTB
movlw b'00000000'
movwf PORTA
btfsc PORTA,7
call Enable
btfsc PORTA,6
call ENRW
btfsc PORTA,5
call RSEN
btfsc PORTA,4
call clrRW
btfsc PORTA,0
call clrRS
goto start
;sub-----------------------------
Enable
bsf PORTA,3
call Delay
bcf PORTA,3
retlw 0x00
ENRW
bsf PORTA,2
call Delay
retlw 0x00
RSEN
bsf PORTA,1
call Delay
retlw 0x00
clrRW
bcf PORTA,2
call Delay
retlw 0x00
clrRS
bcf PORTA,1
call Delay
retlw 0x00
Delay
;0.2sec delay
movlw 0x3F
movwf d1
movlw 0x9D
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
goto $+1
retlw 0x00
end