LEDBUF EQU 30H ;显示码缓存区
HOUR EQU 40H
MINUTE EQU 41H
SECOND EQU 42H
C100US EQU 43H
TICK EQU 10000 ;置中断次数
T100US EQU 256-100 ;置定时器初值
LJMP START ;跳转到主程序
ORG 0003H
LJMP DISPLYLED
RETI
ORG 000BH ;定时器0中断入口
TOINT: PUSH PSW ;状态保护
PUSH ACC
MOV A,C100US+1
JNZ GOOD ;计数值是否为0
DEC C100US
GOOD: DEC C100US+1
MOV A,C100US
ORL A,C100US+1
JNZ EXIT
MOV C100US,#HIGH(TICK) ;重置计数值
MOV C100US+1,#LOW(TICK)
INC SECOND ;秒加一
MOV A,SECOND
CJNE A,#60,EXIT ;判断秒针是否为60
MOV SECOND,#0
INC MINUTE
MOV A,MINUTE
CJNE A,#60,EXIT
MOV MINUTE,#0
INC HOUR
MOV A,HOUR
CJNE A,#24,EXIT
MOV HOUR,#0
EXIT: POP ACC
POP PSW
RETI
DELAY: ; 延时子程序
MOV R7,#0FEH
DELAYLOOP:
DJNZ R7,DELAYLOOP
DJNZ R6,DELAYLOOP ; R6是否有错,是否应改为R7?
RET
LEDMAP: ;数码管显示码
DB 3FH,06H,5BH,4FH
DB 66H,6DH,7DH,07H
DB 7FH,6FH,77H,7CH
DB 39H,5EH,79H,71H
这是我写的程序,怎么实现计时停止?高手赐教! |