...清零程序。对初学者实在是太难了。大神帮帮忙吧!
发布网友
发布时间:2024-10-24 11:24
我来回答
共2个回答
热心网友
时间:2024-11-07 02:23
;---------------------------------------
;http://zhidao.baidu.com/question/485975186.html
;0.0 ~ 9.9
;P0, P2静态显示
;设系统晶振为12MHz。
;按键连接在P3.5,
;按一下,计时,再按一下,停止,再按一下,清零。
;---------------------------------------
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0_INT
;---------------------------------------
ORG 0100H
INIT: ;初始化
MOV P0, #3FH
MOV P2, #3FH
MOV R1, #0
MOV R2, #0
MOV R3, #20
MOV DPTR, #TAB ;表首址送DPTR
MOV TMOD, #01H
MOV TL0, #(65536 - 5000) MOD 256
MOV TH0, #(55536 - 5000) / 256
CLR TR0
CLR P3.6
RET
;---------------------------------------
MAIN:
CALL INIT
MOV R4, #255
SETB ET0
SETB EA
;---------------------------------------
M_LOOP:
JB P3.5, M_LOOP
CALL DLY
JB P3.5, M_LOOP
JNB P3.5, $
INC R4
CJNE R4, #3, M1
MOV R4, #0
M1: CJNE R4, #2, M2
CALL INIT
SJMP M_LOOP
M2: CPL TR0
SJMP M_LOOP
;---------------------------------------
T0_INT:
MOV TL0, #(65536 - 5000) MOD 256
MOV TH0, #(55536 - 5000) / 256
DJNZ R3, T0_E
MOV R3, #20
INC R1
CJNE R1, #10, T0_1
MOV R1, #0
INC R2
CJNE R2, #10, T0_2
MOV R2, #0
MOV P0, #06H
MOV P2, #3FH
SETB P3.6
CLR TR0
MOV R4, #1
RETI
T0_2:
MOV A, R2 ;显示十位
MOVC A, @A + DPTR
SETB ACC.7
MOV P0, A
T0_1:
MOV A, R1 ;显示个位
MOVC A, @A + DPTR
MOV P2, A
T0_E:
RETI
;---------------------------------------
TAB: DB 3FH, 06H, 5BH, 4FH, 66H;0~4
DB 6DH, 7DH, 07H, 7FH, 6FH;5~9
;---------------------------------------
DLY:
MOV R6, #20 ;10ms延时.
D1: MOV R7, #248
DJNZ R7, $
DJNZ R6, D1
RET
;---------------------------------------
END
参考:
http://hi.baidu.com/do_sermon/item/4f921002214f03dbdde5b0c3
热心网友
时间:2024-11-07 02:27
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
ABLE: ; 共阴极数码管显示代码表
DB 3FH,06H,5BH,4FH,66H ;12345
DB 6DH,7DH,07H,7FH ;6789
MAIN:
MOV SP,#5FH
MOV TMOD,#01H
MOV TH0,#HIGH (65536-50000)
MOV TL0,#LOW (65536-50000)
SETB EA
SETB ET0
MOV R2,#0
LOOP:
JB P3.5,$
LCALL DELAY
JB P3.5,LOOP
JNB P3.5,$
INC R2
LOOP1:
MOV A,R2
JNZ LOOP2
SETB TR0
SJMP LOOP
LOOP2:
DEC A
JNZ LOOP3
CLR TR0
SJMP LOOP
LOOP3:
MOV R2,#0
MOV R3,#0
MOV R4,#0
CLR TR0
SJMP LOOP
DELAY:
MOV R6,#20
DELAY1:
MOV R7,#250
DJNZ R7,$
DJNZ R6,DELAY1
RET
T0ISR:
CLR TR0
MOV TH0,#HIGH (65536-50000)
MOV TL0,#LOW (65536-50000)
SETB TR0
INC R0
MOV A,R0
CJNE A,#20,T0E
MOV R0,#0
INC R1
MOV A,R1
CJNE A,#100,T0ISR1
T0ISR1:
JC,T0ISR2
MOV A,#0
T0ISR2:
MOV B,#10
DIV AB
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
MOV A,B
MOVC A,@A+DPTR
MOV P2,A
T0E:
RETI
END