1.程序结构选用主程序和中止服务子程序结构.
2.守时中止程序
守时器1于方法1,16位,10ms中止一次
40H10ms计数单元
41H秒计数单元
42H分计数单元
43H时计数单元
守时方法1为10MS:THX=0ECH,TLX=78H
方法0为10MS: THX=63H,TLX=18H
3.参阅程序
;
DISPEQU0DE00H;显现子程序进口
;
ORG0000H
START:AJMPMAIN
;
ORG001BH;守时器1中止服
AJMPTINT1;务程序进口
;
ORG0030H
MAIN:MOVR0,#39H;显现缓冲区初始化内容来自单片机之家www.dpj100.com
MAIN_0:MOV@R0,#0
INCR0
CJNER0,#44H,#0
MOVTMOD,#10H
MOVIE,#10001000B
MOVTH1,#0ECH;10ms:EC78H
MOVTL1,#78H
SETBTR1
MAIN_1:LCALLDISP;主程序循环
SJMPMAIN_1
;
;守时器1中止服务程序
TINT1:MOVTH1,#0ECH
MOVTL1,#78H
PUSHACC
PUSHPSW
INC40H
MOVA,40H
CJNEA,#100,TINT1R
MOV40H,#0
MOVA,41H;秒单元加1
INCA
DAA
MOV41H,A
CJNEA,#60H,TINT10
MOV41H,#0
MOVA,42H;分单元加1
INCA
DAA
MOV42H,A
CJNEA,#60H,TINT10
MOV42H,#0
MOVA,43H;小时单元加1
INCA
DAA
MOV43H,A
CJNEA,#24H,TINT10
MOV43H,#0
TINT10:MOVA,41H;秒拆字
ANLA,#0FH
MOV39H,A
MOVA,41H
ANLA,#0F0H
SWAPA
MOV3AH,A
MOVA,42H;分拆字
ANLA,#0FH
MOV3BH,A
MOVA,42H
ANLA,#0F0H
SWAPA
MOV3CH,A
MOVA,43H;小时拆字
ANLA,#0FH
MOV3DH,A
MOVA,43H
ANLA,#0F0H
SWAPA
MOV3EH,A
TINT1R:POPPSW
POPACC
RETI