看门狗定时器在掉电模式下应用的例程
ORG 0000H
LJMP START
ORG 0053H
LJMP WDT_ISR
ORG 0100H
WDT_ISR:
CLR EA
MOV TA,#0AAH
MOV TA,#55H
ORL WDCON0,#01000000B ;clear Watchdog Timer counter
INC ACC
MOV P0,ACC
SETB EA
CLR EA
MOV TA,#0AAH
MOV TA,#55H
ANL WDCON0,#11011111B ;clear Watchdog Timer interrupt flag
SETB EA
RETI
START:
MOV TA,#0AAH
MOV TA,#55H
ORL WDCON0,#01000000B ;clear Watchdog Timer counter
MOV TA,#0AAH
MOV TA,#55H
ORL WDCON0,#10000000B ;enable Watchdog Timer to run
Check_clear:
MOV A,WDCON0
JB ACC.6,Check_clear
MOV TA,#0AAH
MOV TA,#55H
ORL WDCON0,#00000111B ;choose interval length
MOV TA,#0AAH
MOV TA,#55H
ANL WDCON1,#11111110B ;disable Watchdog Timer reset
SETB EWDI ;enable Watchdog Timer interrupt
MOV TA,#0AAH
MOV TA,#55H
SETB WIDPD
SETB EA
;********************************************************************
;Enter into Power Down mode
;********************************************************************
LOOP:
ORL PCON,#02H
LJMP LOOP
END
|