Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/20/05 01:13
Read: times


 
#87990 - My keypad program, please verify problem
Responding to: ???'s previous message
Well, currently I am using bray's terminal program.
Thanks to everyone's introduction to other terminal program.

I am able to display something on the screen. For pressing same button, sometimes the MCu able to read, but sometimes, display error message.

Is it something to do with the debouncing? Or the state of keypad is not yet ready for another press and have to wait longer?
my connection is to all Port 1 for 4x4 matrix keypad, with no interrupt.

Another problem is regarding Column. My column 3 can't detect anything. Which is button of 3,6,9,# cant function at all. Is it because port1.7 spoilt? right here I attached my program.

org 8000h
start:

poll:
lcall keypressed
jnc poll
lcall findrow
mov b,a
jnc getcolumn
lcall print
db "Error - Key row not found", 0
lcall crlf

kp1:
lcall keypressed
jc kp1
sjmp start

getcolumn:
lcall findcolumn
swap a
orl a, b
mov b, a
jnc reportkey

lcall print
db "Error - key row not dound", 0
lcall crlf

kp2:
lcall keypressed
jc kp2
sjmp start

reportkey:
lcall displaykey
lcall convertkey
lcall display
mov sbuf, a

kp3:
lcall keypressed
jc kp3
ljmp start

keypressed:
mov p1, #0Fh
mov a, p1
orl a, #0f0h
cpl a
jz nokey
setb C
ret

nokey:
clr C
ret

findrow:
mov a, p1
mov r0, #4

trynextrow:
rrc a
jnc rowfound
djnz r0, trynextrow
setb C
ret

rowfound:
mov a, #4
subb a, r0
clr C
ret

findcolumn:
mov r0, #4
mov a, #0EFh
push acc

trynextcolumn:
pop acc
mov p1, a
rl a
push acc
mov a, p1
orl a, #0f0h
cpl a
jnz columnfound
djnz r0, trynextcolumn
pop acc
setb C
ret

columnfound:
pop acc
mov a, #4
clr C
subb a, r0
clr C
ret

displaykey:
lcall print
db "Key Pressed - column and row: ", 0
mov a, b
lcall prthex
lcall crlf
ret

convertkey:
mov a, b
rl a
rl a
mov C, acc.6
mov acc.0, C
mov C, acc.7
mov acc.1, C
anl acc, #0fh
ret

crlf:
mov a, #0dh
lcall sndchr

sndchr:
clr ti
mov sbuf, a

delay:
dec a
d_olp:
push acc
mov a, #0a6h
d_ilp:
inc a
nop
nop
nop
nop
nop
nop
nop
nop
jnz d_ilp
nop
nop
nop
pop acc
djnz acc, d_olp
mov a, #0a6h
d_lp2:
inc a
nop
nop
nop
nop
nop
nop
nop
nop
jnz d_lp2
nop
nop
nop
nop
nop
ret

display:
inc a
movc a, @a+pc
ret
db 0c0h
db 0f9h
db 0a4h
db 0b0h
db 99h
db 92h
db 82h
db 0f8h
db 80h
db 90h
db 88h
db 83h
db 0c6h
db 0a1h
db 86h
db 8eh

getchr:
jnb ri, getchr
mov a, sbuf
clr acc.7
clr ri
ret

inkey:
mov a, #00h
jnb ri, doneik
mov a, sbuf
anl a, #7fh
clr ri
doneik:
ret

prthex:
lcall binasc
lcall sndchr 
mov a, r2
lcall sndchr
ret

binasc:
mov r2, a
anl a, #0fh
add a, #0f6h
jnc noadj1
add a, #07h
noadj1:
add a, #3ah
xch a, r2

swap a
anl a, #0fh
add a, #0f6h
jnc noadj2
add a, #07h
noadj2:
add a, #3ah
ret

print:
pop dph
pop dpl
prtstr:
clr a
movc a, @a+dptr
cjne a, #0h, mchrok
sjmp done

mchrok:
lcall sndchr
inc dptr
ljmp prtstr
done:
mov a, #1h
jmp @a+dptr

end





List of 23 messages in thread
TopicAuthorDate
How to display keypad press on PC screen            01/01/70 00:00      
   Keypad            01/01/70 00:00      
      Mistake!            01/01/70 00:00      
         How many buttons?            01/01/70 00:00      
   Break up the project...            01/01/70 00:00      
      Use HyperTerm for Recv & Displ            01/01/70 00:00      
         Full Hypoterminal settings            01/01/70 00:00      
            HEX Displ -Try other Term Emalua Pck            01/01/70 00:00      
               Simple but good            01/01/70 00:00      
                  TERM95            01/01/70 00:00      
                     My keypad program, please verify problem            01/01/70 00:00      
                        A suggestion            01/01/70 00:00      
                           Commenting - may answer own question!            01/01/70 00:00      
   Port can be spoilt?            01/01/70 00:00      
      please clarify            01/01/70 00:00      
         Both also I tried before            01/01/70 00:00      
            remarks            01/01/70 00:00      
               How to transmit cr twice?            01/01/70 00:00      
                  eh??            01/01/70 00:00      
                  CR twice            01/01/70 00:00      
                     To CR or not to CR :-)            01/01/70 00:00      
                        Delay are not suppose to get rid            01/01/70 00:00      
   knowing the derivative would be nice            01/01/70 00:00      

Back to Subject List