sz acc ;if any input?
jmp get_key ;yes. get input info
MOV a,0fbh ;(2);no. scan third row
MOV matrix,a ;hold scan code
MOV pac,a ;pa.2 output 0 (latch)
MOV a,pa ;read input state
cpl acc ;;distill input state
and a,0f0h ;;
sz acc ;if any input?
jmp get_key ;yes. get input info
MOV a,0f7h ;(2);no. scan fourth row
MOV matrix,a ;hold scan code
MOV pac,a ;output pa.3 0 (latch)
MOV a,pa ;read input state
cpl acc ;;distill input state
and a,0f0h ;;
sz acc ;if any input?
jmp get_key ;yes. get input info
jmp keyloop ;repeat from keyloop
get_key: ;get input key info
call delays ;debounce
MOV a,pa ;test port A
or a,0fh ;
cpl acc ;
sz acc ;any key hold?
jmp go_on ;yes. go on (some key is pressed)
jmp keyloop ;no. return to scan key again
go_on:
call key_in ;(3) ;calculate table index
tabrdl disp ;(10);load display data
MOV a,disp ;;output data to port B
MOV pb,a ;(11);;
jmp keyloop ;repeat keyloop
key_in proc ;get key number
MOV a,pa ;;hold port A state
MOV temp,a ;(4) ;;
get_release: ;wait for the key to be released
MOV a,pa ;;test port A state
cpl acc ;;
and a,0f0h ;;
sz acc ;(6) ;if release?
jmp get_release ;no. keep up waiting
MOV a,0fh ;yes. calculate key number
andm a,matrix ;(7) ;mask low nibble of scan code
MOV a,0 ;keep table index at register A
上一页 [1] [2] [3] 下一页
本文关键字:单片机 程序 键盘 合泰单片机,单片机-工控设备 - 合泰单片机