自己变得一个51汇编倒计时程序,
自己写的一个51单片机 汇编倒计数程序,从 15分47秒,开始到计时。可是数码管,不能正常显示,个位大大帮小弟看看吧。谢谢了DISBUF0 EQU 30H
DISBUF1 EQU 31H
DISBUF2 EQU 32H
DISBUF3 EQU 33H
TIME_S EQU 40H
TIME_N EQU 41H
ORG 0000H
AJMP MAIN
ORG 000BH
AJMP T0_SR
MAIN:
CALL T0init
MOV R2,#0
MOV R3,#0
MOV 30H,#1
MOV 31H,#5
MOV 32H,#4
MOV 33H,#7
L2: CALL DISP
JMP L2
T0init:
MOV TMOD, #01H
MOV TH0,#HIGH(-10000)
MOV TL0,#LOW(-10000)
SETB ET0
SETB EA
SETB TR0
RET
T0_SR:
PUSH PSW
PUSH ACC
INC R2
CJNE R2,#100,ENDOK
MOV R2,#0
MOV TIME_N,#15
MOV TIME_S,#47
DEC TIME_S
MOV A,TIME_S
CJNE A,#0,L1
MOV TIME_S,#59
DEC TIME_N
MOV A,TIME_N
CJNE A,#0,L1
MOV TIME_N,#59
L1: CALL H2BCD
ENDOK: CLR TR0
MOV TH0,#high(-10000)
MOV TL0,#low(-10000)
SETB TR0
POP ACC
POP PSW
RETI
H2BCD:
MOV A, TIME_S
MOV B,#10
DIV AB
MOV 33H,A
MOV 32H,B
MOV A,TIME_N
MOV B,#10
DIV AB
MOV 31H,A
MOV 30H,B
RET
DISP:
MOV R0,#30H
MOV R4,#4
MOV R1,#0FEH
LOOP: MOV A,@R0
MOV DPTR,#DISCODE
MOVC A,@A+DPTR
MOV P0,A
MOV P1,R1
CALL DELAY
MOV P1,#0FFH
INC R0
MOV A,R1
RL A
MOV R1,A
DJNZ R4,LOOP
RET
DELAY: MOV R6,#4H
DE1: MOV R5,#150
DE2: MOV R4,#150
DJNZ R4,$
DJNZ R5,DE2
DJNZ R6,DE1
RET
RET
DISCODE: DB 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71
END