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

Back to Subject List

Thread Closed: Issue successfully resolved

???
12/27/04 07:15
Read: times


 
#83912 - calculator style key pad
I’m trying to design a key pad with 4 digits led readout, the key pad connects to p1 of an 89s52 mcu and p0 to drive the segments,the led are toggle by p2.0 for unit led p2.1 for ten p2.2 for hundred and p2.3 for the thousand digit my key pad code works correctly. It displays correct digit acording to the button but when I tried to display all four digits I goofed off

in_hex:
mov r3,#10 ; debounce count
back:
lcall get_key ; key pressed?
jnc in_hex ; no - check again
djnz r3,back ; yes - repeat 50 times
push acc ; save key code
back2:
mov r3,#10 ; wait for key release
back3:
lcall get_key ; key still pressed?
jc back2 ; yes - keep checking
djnz r3,back3 ; no - repeat 50 times
pop acc
ret
; =============================================================
; get keypad status - return with C = 0 if no key pressed
; return with C = 1, and hex code in acc. if pressed
; =============================================================

get_key:
mov a,#0feh
mov r6,#4
test: mov p1,a
mov r7,a
mov a,p1
anl a,#0f0h
cjne a,#0f0h,key_hit
mov a,r7
rl a
djnz r6,test
clr c
sjmp exit

key_hit:
mov r7,a
mov a,#4
clr c
subb a,r6
mov r6,a
mov a,r7
swap a
mov r5,#4
again:
rrc a
jnc done
inc r6
inc r6
inc r6
inc r6
djnz r5,again
done:
setb c
mov a,r6
mov unit,a
mov count1,a
xch a,count1
mov count1,a
xch a,count2
mov count2,a
mov a,count2
xch a,count3
mov count3,a
mov a,count3
xch a,count4
mov count4,a
exit:
ret
this is the timer0 int routine
up_date:
push acc ; caát noäi dung reg a
push psw ; caát luoân reg b

mov th0, #0d4h ; ñaët trò cho caùc timer reg
mov tl0, #0c7h ; ñeå taïo khoaûng ñeám 1/100 giaây
setb et0 ;(tính caû 2 leänh mov vaø 6 xung clock laø thôøi gian leát ñöôïc tôùi ñaây)

mov a,count
add a, #01h ; khôûi taïo counter 1/100 second
cjne a, #00h, end_int ; ñöôïc 1 second chöa, neáu chöa nhaåy tôùi end_t0_int
mov a,#050h
lcall display_don_vi
lcall delayms
lcall display_chuc
lcall delayms
lcall display_tram
lcall delayms
lcall display_ngan
lcall delayms
end_int:
pop psw
pop acc
reti
what I want is to enter the number caculator style when I push a key the number should shift left to right. Please give me some advice.
thanks


List of 4 messages in thread
TopicAuthorDate
calculator style key pad            01/01/70 00:00      
   strange mov-s and xch-s            01/01/70 00:00      
      strange mov-s and xch-s            01/01/70 00:00      
   calculator style key pad            01/01/70 00:00      

Back to Subject List