利用51单片机,通过两位数码管显示秒,按键实现计时和停止计时 具体内容内详
如果好的话再追加100分
可以没有hex 展开
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-10000)
MOV TL0,#LOW(65536-10000)
SETB ET0
SETB EA
MOV R0,#0
MOV R1,#0
MOV R2,#0
MOV R3,#9
CLR 00H
CLR 01H
LOOP:
JB P1.0,LP01
JNB P1.0,$
SETB TR0
CLR 01H
SJMP LOOP0
LP01:
JB P1.1,LP02
JNB P1.1,$
SETB 01H
SJMP LOOP0
LP02:
JB P1.2,LOOP0
JNB P1.1,$
CLR TR0
MOV P3,#0FDH
MOV P2,#0
MOV P3,#0FEH
MOV P2,#0
SJMP MAIN
LOOP0:
JB 00H,LOOP1
MOV A,R0
SJMP LOOP2
LOOP1:
MOV A,R1
LOOP2:
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV R3,A
SJMP LOOP
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-10000)
MOV TL0,#LOW(65536-10000)
SETB TR0
JB 01H,T0C
INC R2
T0C:
CPL 00H
MOV A,R3
JB 00H,T001
MOV P3,#0FDH
MOV P2,A
SJMP T002
T001:
MOV P3,#0FEH
MOV P2,A
T002:
MOV A,R2
CJNE A,#100,T0E
MOV R2,#0
INC R0
CJNE R0,#10,T0E
MOV R0,#0
INC R1
CJNE A,#10,T0E
MOV R1,#0
T0E:
RETI
T004:
CLR TR0
RETI
TABLE: ; 共阴极数码管显示代码表
DB 3FH,06H,5BH,4FH,66H ;01234
DB 6DH,7DH,07H,7FH,6FH ;56789
END
2014-01-29 · 知道合伙人数码行家