利用独立键盘和4位一体七段LED数码管,分别完成以下实验内容:
1.使用4位一体七段LED数码管的个位,设计一台仅有个位的秒表,要求:
1)每一秒钟到,数码管自动加 1 并显示。(提示:可用静态显示方式,时间累计用延时实现)
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV DPTR,#TAB
MOV P0,#0
MOV P1,#0FFH
MOV R0,#0
NXT: MOV A,R0
MOVC A,@A+DPTR
MOV P1,A
INC R0
LCALL DELAY
CJNE R0,#10,NXT
LJMP MAIN
DELAY:
MOV R7,#10
LOOP1: MOV R6,#200
LOOP2: MOV R5,#249
LOOP3: DJNZ R5,LOOP3
DJNZ R6,LOOP2
DJNZ R7,LOOP1
RET
TAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
;TAB: DB C0H,F9H,A4H,B0H,99H,92H,82H,F8H,80H,90H 共阴极与共阳极之分
2.使用4位一体七段LED数码管的4个位,设计一台多位的秒表,要求:文章来源:https://www.toymoban.com/news/detail-505735.html
1)每一秒钟到,数码管自动加 1 并显示。(提示:可用动态显示方式,时间累计用定时器中断实现) 文章来源地址https://www.toymoban.com/news/detail-505735.html
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV R0,#0
MOV R1,#0
MOV R2,#0
MOV R3,#0
MOV R6,#0
MOV R7,#0
MOV 50H,#160
MOV R4,50H
CLR C
MOV DPTR,#TAB
LOOP: LCALL DISP1
MOV A,R6
MOV 30H,R7
CJNE A,30H,SKIP1
LJMP NEXT
SKIP1: MOV A,R7
SUBB A,R6
JNB CY,NEXT
MOV A,R6
MOV R7,A
CLR C
CJNE R7,#1,NEXT21
MOV 50H,#80
NEXT21: CJNE R7,#2,NEXT22
MOV 50H,#53
NEXT22: CJNE R7,#3,NEXT
MOV 50H,#40
NEXT: DJNZ R4,SKIP2
LJMP LOOP
SKIP2:
MOV R4,50H
INC R0
CJNE R0,#10,LOOP
MOV R0,#0
MOV R6,#1
INC R1
CJNE R1, #10, LOOP
MOV R1, #0
MOV R6, #2
INC R2
CJNE R2, #10, LOOP
MOV R2, #0
MOV R6, #3
INC R3
CJNE R3, #10, LOOP
MOV R3, #0
LJMP LOOP
DISP1:
MOV P1, #01111111B
MOV A, R0
MOVC A, @A+DPTR
MOV P0, A
LCALL DELAY
CJNE R7, #1, NEXT11
LCALL DISP2
NEXT11: CJNE R7, #2, NEXT12
LCALL DISP2
NEXT12: CJNE R7, #3, NEXT13
LCALL DISP2
NEXT13: RET
DISP2:
MOV P1, #10111111B
MOV A, R1
MOVC A, @A+DPTR
MOV P0, A
CJNE R7, #2, NEXT21
LCALL DISP3
NEXT21: CJNE R7, #3, NEXT22
LCALL DISP3
NEXT22: RET
DISP3:
MOV P1, #11011111B
MOV A, R2
MOVC A, @A+DPTR
MOV P0, A
LCALL DELAY
CJNE R7, #3, NEXT31
LCALL DISP4
NEXT31: RET
DISP4:
MOV P1, #11101111B
MOV A, R3
MOVC A, @A+DPTR
MOV P0, A
LCALL DELAY
NEXT4: RET
DELAY:
MOV R5, #12
LOOP1: MOV B, #248
DJNZ B, $
DJNZ R5, LOOP1
RET
TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
到了这里,关于单片机实验——键盘与显示实验的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!