HT48R50A的4X4按键显示程序
扫描二维码
随时随地手机看文章
; ********************************************
; Function : 4X4按键,数码管显示程序 *
; MICroProcessor : HT48R50A-1/28SKDIP-A *
; Author: www.picavr.com *
; Crystal : 4MHz *
; ********************************************
#INCLUDE HT48R50A-1.INC
;---------------------------------------------
DATA .SECTION AT 60H 'DATA'
DISPLAY_DATA DB ? ;[60H]
DISPLAY_COUNTER DB ? ;[61H]
SCAN_COUNTER DB ? ;[62H]
SCAN_DATA DB ? ;[63H]
SCAN_CODE DB ? ;[64H]
;---------------------------------------------
CODE .SECTION AT 00H 'CODE'
ORG 00H
JMP START
START:
MOV A,0FH
MOV PAC,A
SET PA
CLR PBC
CLR PB
SCAN_BEGIN:
MOV A,04H
MOV SCAN_COUNTER,A
MOV A,70H
MOV SCAN_DATA,A
SCAN_NEXT:
MOV PA,A
CALL KEY_IN
SET C
RRC SCAN_DATA
MOV A,SCAN_DATA
AND A,0F0H
SDZ SCAN_COUNTER
JMP SCAN_NEXT
JMP SCAN_BEGIN
RET
;---------------------------------------------
; 4x4 Keyboard code
ORG 0E00H
DC 077H,07BH,07DH,07EH ;0123
DC 0B7H,0BBH,0BDH,0BEH ;4567
DC 0D7H,0DBH,0DDH,0DEH ;89AB
DC 0E7H,0EBH,0EDH,0EEH ;CDEF
KEY_IN PROC
CLR TBLP
MOV A,10H
MOV DISPLAY_COUNTER,A
SCAN_KEY:
TABRDL DISPLAY_DATA
TABRDC SCAN_CODE
INC TBLP
MOV A,PA
SUB A,SCAN_CODE
SZ ACC
JMP NEXT_CODE
MOV A,DISPLAY_DATA
MOV PB,A
KEY_STATUS:
MOV A,PA
AND A,0FH
XOR A,0FH
SZ ACC
JMP KEY_STATUS
JMP OVER
NEXT_CODE:
SDZ DISPLAY_COUNTER
JMP SCAN_KEY
OVER:
RET
KEY_IN ENDP
;---------------------------------------------
; 7-Segment(Common andoe) display code
ORG 0F00H
DC 081H,0CFH,092H,086H ;0123
DC 0CCH,0A4H,0A0H,08FH ;4567
DC 080H,084H,088H,0E0H ;89AB
DC 0B1H,0C2H,0B0H,0B8H ;CDEF
;---------------------------------------------
END