d@nny
Full Member level 5
here is picture of my LG remote with keys press 0 , 1 , to , 9 .
How should i scan this keys into the PIC16F76?????/
i am using the following time delays in interrupt routine and watching them on cd4094 shift register with the help of PORTC. But it is not correct at all and i cant find a way to scan them so no two keys present me the same code as currently this programme doing?
d1 equ 21h
d2 equ 22h
d3 equ 23h
r1 equ 24h
org 0x00
goto main
org 0x04
goto INTR
main:
banksel ANSEL
movlw B'00000000'
movwf ANSEL
banksel PORTA
clrf PORTA
banksel TRISA
movlw b'00000100'
movwf TRISA
banksel PORTC
clrf PORTC
banksel TRISC
clrf TRISC
banksel INTCON
bcf OPTION_REG , INTEDG
bsf INTCON , INTE
bcf INTCON , INTF
bsf INTCON , GIE
FIN:
goto FIN
INTR:
banksel PORTC
clrf PORTC
clrf r1
call De175ms ;1.75ms
call De28ms ; 2.8ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call de500ms
call serout
bsf PORTC , 5
bsf PORTC , 5
banksel INTCON
bcf INTCON , INTF
nop
nop
nop
nop
nop
retfie
scan:
btfsc PORTA , 2
goto one
goto zero
zero:
bcf STATUS , 0
rlf r1 , 1
one:
bsf STATUS , 0
rlf r1 , 1
return
de500ms:
movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
De500_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto De500_0
;6 cycles
goto $+1
goto $+1
goto $+1
return
De28ms:
movlw 0xF3
movwf d1
movlw 0x02
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
;2 cycles
goto $+1
return
De175ms:
movlw 0x5D
movwf d1
movlw 0x02
movwf d2
Delay_01
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_01
;2 cycles
goto $+1
return
serout:
movlw 0x08
movwf d3
testbit:
bcf PORTC , 4
btfsc r1 , 7
bsf PORTC , 4
bsf PORTC , 3
bcf PORTC , 3
rlf r1 , f
decfsz d1 , f
goto testbit
return
end
How should i scan this keys into the PIC16F76?????/
i am using the following time delays in interrupt routine and watching them on cd4094 shift register with the help of PORTC. But it is not correct at all and i cant find a way to scan them so no two keys present me the same code as currently this programme doing?
d1 equ 21h
d2 equ 22h
d3 equ 23h
r1 equ 24h
org 0x00
goto main
org 0x04
goto INTR
main:
banksel ANSEL
movlw B'00000000'
movwf ANSEL
banksel PORTA
clrf PORTA
banksel TRISA
movlw b'00000100'
movwf TRISA
banksel PORTC
clrf PORTC
banksel TRISC
clrf TRISC
banksel INTCON
bcf OPTION_REG , INTEDG
bsf INTCON , INTE
bcf INTCON , INTF
bsf INTCON , GIE
FIN:
goto FIN
INTR:
banksel PORTC
clrf PORTC
clrf r1
call De175ms ;1.75ms
call De28ms ; 2.8ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call de500ms
call serout
bsf PORTC , 5
bsf PORTC , 5
banksel INTCON
bcf INTCON , INTF
nop
nop
nop
nop
nop
retfie
scan:
btfsc PORTA , 2
goto one
goto zero
zero:
bcf STATUS , 0
rlf r1 , 1
one:
bsf STATUS , 0
rlf r1 , 1
return
de500ms:
movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
De500_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto De500_0
;6 cycles
goto $+1
goto $+1
goto $+1
return
De28ms:
movlw 0xF3
movwf d1
movlw 0x02
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
;2 cycles
goto $+1
return
De175ms:
movlw 0x5D
movwf d1
movlw 0x02
movwf d2
Delay_01
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_01
;2 cycles
goto $+1
return
serout:
movlw 0x08
movwf d3
testbit:
bcf PORTC , 4
btfsc r1 , 7
bsf PORTC , 4
bsf PORTC , 3
bcf PORTC , 3
rlf r1 , f
decfsz d1 , f
goto testbit
return
end