ORG 0000H
LJMP MAIN
ORG 0040H
SH_C EQU 41H
G_C EQU 42H
SECOND EQU 43H
DULA BIT P2.6;
WELA BIT P2.7;
ORG 0100H
MAIN:
MOV A,SECOND
CJNE A,#0,LOOP1
MOV SECOND,#60;
LOOP1: MOV A,SECOND
MOV B,#10
DIV AB
MOV SH_C,A
MOV G_C,B
MOV 30H,#40H
LOOP: CALL DISPLAY
DJNZ 30H,LOOP
DEC SECOND
CALL DELAYXMS1
AJMP MAIN
DELAYXMS1:MOV R0,#8
L1:MOV R1,#250
L2:MOV R2,#250
DJNZ R2,$
DJNZ R1,L2
DJNZ R0,L1
RET
DELAYXMS:MOV 52H,#250 ;50H,51H,52H用于延时 50H为参数X 延时1*X MS
DELAYA: MOV 51H,#250
MOV 50H,#200
NOP
DJNZ 51H,$
DJNZ 52H,DELAYA
DJNZ 50H,DELAYXMS
RET ;延时返回
DISPLAY: ;显示程序
MOV DPTR,#TABL
CLR DULA;
MOV A,SH_C
MOVC A,@A+DPTR
MOV P0,A ;显示十位
SETB DULA;
CLR DULA;
CLR WELA;
MOV P0,#7EH;
SETB WELA;
CLR WELA;
MOV 50H,#200
CALL DELAYXMS
MOV A,G_C
MOVC A,@A+DPTR
MOV P0,A ; ;显示个位
SETB DULA;
CLR DULA;
MOV P0,#7DH;
SETB WELA;
CLR WELA;
MOV 50H,#200
CALL DELAYXMS
RET
TABL: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H
DB 7FH,6FH,77H,7CH,39H,5EH,79H,71H
END
已完成倒计时,只是太快,求1s变化一次。
|