新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)/智能儀表顯示與鍵盤設(shè)計(jì)

單片機(jī)/智能儀表顯示與鍵盤設(shè)計(jì)

作者: 時(shí)間:2016-11-18 來(lái)源:網(wǎng)絡(luò) 收藏

實(shí)驗(yàn)內(nèi)容:鍵盤采用4X4鍵盤,每個(gè)數(shù)碼管顯示值可為0-F共16個(gè)數(shù)。通過(guò)按鍵,求取鍵值0-F在R5寄存器中。通過(guò)按鍵,編寫(xiě)程序掃描鍵盤輸入,并將掃描結(jié)果送數(shù)碼管顯示。實(shí)現(xiàn)對(duì)應(yīng)不同按鍵在數(shù)碼管上顯示相應(yīng)鍵值0-F的功能。

本文引用地址:http://butianyuan.cn/article/201611/315737.htm

參考程序:

ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV R1,#7AH
MOV R2,#06H
MOV A,#00H
L01:MOV @R1,A
INC R1
DJNZ R2,L01
LCALL DIR6
MA1:LCALL KEY
MOV A,R5
MOV R1,#7AH
MOV R2,#06H
L02:MOV @R1,A
INC R1
DJNZ R2,L02
LCALL DIR6
NOP
SJMP MA1
KEY: MOV DPTR,#7F03H
MOV A,#81H
MOVX @DPTR,A
MOV R4,#00H
MOV R2,#0FEH
KEY1:MOV DPTR,#7F00H
MOV A,R2
MOVX @DPTR,A
MOV DPTR,#7F02H
MOVX A,@DPTR
JB ACC.0,KEY2
MOV A,#00H
AJMP KEY5
KEY2:JB ACC.1,KEY3
MOV A,#01H
AJMP KEY5
KEY3:JB ACC.2,KEY4
MOV A,#02H
AJMP KEY5
KEY4:JB ACC.3,NEXT
MOV A,#03H
KEY5:ADD A,R4
MOV R4,A
MOV R5,A
RET
NEXT:MOV A,R4
ADD A,#04H
MOV R4,A
MOV A,R2
JNB ACC.3,NEXT1
RL A
MOV R2,A
AJMP KEY1
NEXT1:RET
DIR6:MOV R0,#7AH
MOV R3,#0FEH
MOV A,R3
DISP1:MOV DPTR,#7F00H
MOVX @DPTR,A
INC DPTR
MOV A,@R0
ADD A,#0DH
MOVC A,@A+PC
MOVX @DPTR,A
ACALL DELAY
INC R0
MOV A,R3
JNB ACC.5,DISP2
RL A
MOV R3,A
AJMP DISP1
DISP2:RET
SEGPT:DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H,73H
DELAY:MOV R5,#08H
DELAY1:MOV R4,#0FFH
DELAY2:DJNZ R4,DELAY2
DJNZ R5,DELAY1
RET
END



評(píng)論


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

關(guān)閉