新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)匯編實(shí)驗(yàn)七:掃描鍵盤及液晶顯示實(shí)驗(yàn)

單片機(jī)匯編實(shí)驗(yàn)七:掃描鍵盤及液晶顯示實(shí)驗(yàn)

作者: 時(shí)間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
實(shí)驗(yàn)要求:利用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; // 液晶數(shù)據(jù)/命令選擇端口
sbit lcden=P2^5; //液晶使能端
sbitlcdrw=P1^1; //讀寫選擇端口
sbit wei=P2^7;
sbit duan=P2^6;
//
MAIN:
CALL INTE
MOV DPTR,#TABLE
SCAN: //檢測(cè)第一行
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

//檢測(cè)第二行
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
//檢測(cè)第三行
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

//檢測(cè)第四行
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

上一頁(yè) 1 2 下一頁(yè)

評(píng)論


技術(shù)專區(qū)

關(guān)閉