试验要求:使用P1口与行列式键盘接口,编写键盘扫描程序,把按键输入的键码,显现在LCD液晶显现器上。
//This is the seventh program of the homework;
//Thisprogramis made by Wang Qi Date:2013/3/7
ORG 0000H
sjmp main
org 0050h
//
sbit lcdrs=P1^0; // 液晶数据/指令挑选端口
sbit lcden=P2^5; //液晶使能端
sbitlcdrw=P1^1; //读写挑选端口
sbit wei=P2^7;
sbit duan=P2^6;
//
MAIN:
CALL INTE
MOV DPTR,#TABLE
SCAN: //检测榜首行
MOV P3,#0FEH;
MOV A,P3
ANL A,#0F0H
XHPD0: CJNE A,#0F0H,OK0
SJMP NO1
OK0: CALL DELAY0
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,MM0
SJMP XHPD0
MM0: CJNE A,#0E0H,MM1
MOV R1,#01H
CALL JIEDIAN
MM1: CJNE A,#0D0H,MM2
MOV R1,#02H
CALL JIEDIAN
MM2: CJNE A,#0B0H,MM3
MOV R1,#03H
CALL JIEDIAN
MM3: CJNE A,#070H,XHPD0
MOV R1,#04H
CALL JIEDIAN
//检测第二行
NO1: MOV P3,#0FDH;
MOV A,P3
ANL A,#0F0H
XHPD1: CJNE A,#0F0H,OK1
//CALL JIEDIAN
SJMP NO2
OK1: CALL DELAY0
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,MM00
SJMP XHPD1
MM00: CJNE A,#0E0H,MM10
MOV R1,#05H
CALL JIEDIAN
MM10: CJNE A,#0D0H,MM20
MOV R1,#06H
CALL JIEDIAN
MM20: CJNE A,#0B0H,MM30
MOV R1,#07H
CALL JIEDIAN
MM30: CJNE A,#070H,XHPD1
MOV R1,#08H
CALL JIEDIAN
//检测第三行
NO2: MOV P3,#0FBH;
MOV A,P3
ANL A,#0F0H
XHPD2: CJNE A,#0F0H,OK2
SJMP NO3
OK2: CALL DELAY0
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,MM01
SJMP XHPD2
MM01: CJNE A,#0E0H,MM11
MOV R1,#09H
CALL JIEDIAN
MM11: CJNE A,#0D0H,MM21
MOV R1,#0AH
CALL JIEDIAN
MM21: CJNE A,#0B0H,MM31
MOV R1,#0BH
CALL JIEDIAN
MM31: CJNE A,#070H,XHPD2
MOV R1,#0CH
CALL JIEDIAN
//检测第四行
NO3: MOV P3,#0F7H;
MOV A,P3
ANL A,#0F0H
XHPD3: CJNE A,#0F0H,OK3
LJMP SCAN
OK3: CALL DELAY0
MOV A,P3
ANL A,#0F0H
CJNE A,#0F0H,MM40
SJMP XHPD3
MM40: CJNE A,#0E0H,MM41
MOV R1,#0DH
CALL JIEDIAN
MM41: CJNE A,#0D0H,MM42
MOV R1,#0EH
CALL JIEDIAN
MM42: CJNE A,#0B0H,MM43
MOV R1,#0FH
CALL JIEDIAN
MM43: CJNE A,#070H,XHPD3
MOV R1,#10H
CALL JIEDIAN
LJMP scan
JIEDIAN:
DEC R1
MOV A,R1
MOVC A,@A+DPTR
CALL WRITE_DATE
CALL DELAY
SETB P2.6
MOV P0,A
CLR P2.6
RET