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
Ok, but how can i get it low?
I am using the QL200 Dev board, and the switch is connected like this:
start ;Switch interactions
movlw b'00001111'
movwf PORTB
movlw b'00000000' ' but [B]here you are turning AN1 off[/B]
movwf PORTA
btfsc PORTA,7
call Enable
btfsc PORTA,6
call ENRW
btfsc PORTA,5; [B]switch pressed so call AN1 on[/B]
call RSEN
btfsc PORTA,4
call clrRW
btfsc PORTA,0
call clrRS
goto start
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
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
Hi
On an unrelated note, what program are you using to get the MCU pin outs? It looks very good.
Tom
hi,
EDIT:
How long are the wires to the switch.?
They are about 30cm long.
hi Roger,
For a test, shorten the wires down to say 5cms and twist them together, the problem may be caused by the long 30cm wires, lets know.
Hi Eric,
I discoverd the error! I feel stupid for not cheking this erlier... The RA5 pin is as you know the VPP pin.. On my dev board the vpp signal is high even when its not receiving any program. The developers of this dev board did not emplement a link witch they should have so I could deactivate the vpp input while onboard testing! I'll just use a bigger Chip with more PORTS..
Thanks for all the good help!
Cheers!
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?