Chương4
:Chương trình quét bàn phím ma trận 4X4 và
nh
ập số liệu từ bàn phím:
;==================================================
========= ===
NUMBER_A1:;DO KHONG NHAY DUOC
LJMP NUMBER_A
SCAN_KEYPAD:
CLR KEYPRESS
SCAN_KEYPAD1: ;KEYPAD = P2
MOV KEYPAD,#0FFH;QUET HANG 1
CLR P2.0
NOP
MOV A,KEYPAD
JNB ACC.4,NUMBER_7
JNB ACC.5,NUMBER_8
JNB ACC.6,NUMBER_9
JNB ACC.7,NUMBER_A1
MOV KEYPAD,#0FFH;QUET HANG 2
CLR P2.1
NOP
MOV A,KEYPAD
JNB ACC.4,NUMBER_4
JNB ACC.5,NUMBER_5
JNB ACC.6,NUMBER_6
JNB ACC.7,NUMBER_B
MOV KEYPAD,#0FFH;QUET HANG 3
CLR P2.2
NOP
MOV A,KEYPAD
JNB ACC.4,NUMBER_1
JNB ACC.5,NUMBER_2
JNB ACC.6,NUMBER_3
JNB ACC.7,NUMBER_C
MOV KEYPAD,#0FFH;QUET HANG 4
CLR P2.3
NOP
MOV A,KEYPAD
JNB ACC.4,KEY_ENTER
JNB ACC.5,NUMBER_0
JNB ACC.6,KEY_ESC
JNB ACC.7,NUMBER_D
JB KEYPRESS,EXIT_SCAN
LJMP SCAN_KEYPAD1
NUMBER_1:
MOV R4,#1H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_2:
MOV R4,#2H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_3:
MOV R4,#3H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_4:
MOV R4,#4H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_5:
MOV R4,#5H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_6:
MOV R4,#6H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_7:
MOV R4,#7H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_8:
MOV R4,#8H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_9:
MOV R4,#9H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_0:
MOV R4,#00H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_A:
MOV R4,#0AH
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_B:
MOV R4,#0BH
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_C:
MOV R4,#0CH
SETB KEYPRESS
LJMP SCAN_KEYPAD1
NUMBER_D:
MOV R4,#0DH
SETB KEYPRESS
LJMP SCAN_KEYPAD1
KEY_ENTER:
MOV R4,#13H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
KEY_ESC:
MOV R4,#27H
SETB KEYPRESS
LJMP SCAN_KEYPAD1
EXIT_SCAN: ;thoat khoi quet ban phim
MOV A,R4
RET