ORG | 0000H | |||
AJMP | MAIN | |||
ORG | 000BH | |||
LJMP | ERR | |||
MAIN: | MOV | SP, | #60H | |
MOV | PSW, | #00H | ||
MOV | SCON, | #00H | ||
MOV | TMOD, | #01H | ;设置T0为16位定时器 | |
SETB | ET0 | ;允许T0中断 | ||
SETB | PT0 | ;设置T0中断为高级中断 | ||
MOV | TL0, | #00H | ;设定T0的定时初值,定时时间约为16ms(6M晶振) | |
MOV | TH0, | #0B0H | ||
SETB | EA | ;开中断 | ||
SETB | TR0 | ;启动T0 | ||
LOOP: | ...... | ;主程序开始 | ||
LCALL | WATCH DOG | ;调用喂狗子程序 | ||
...... | ||||
LJMP | LOOP | |||
WATCH DOG: | MOV | TL0, | #00H | ;喂狗子程序 |
MOV | TH0, | #0B0H | ||
SETB | TR0 | |||
RET | ||||
ERR: | POP | ACC | ||
POP | ACC | |||
CLR | A |
PUSH | ACC | |||
PUSH | ACC | |||
RETI |