MS51
Nov. 28, 2019 Page 356 of 491 Rev 1.00
MS51 32K SERIES TECHNICAL REFERENCE MANUAL
be set while the WDT completes the selected time interval. The software polls the WDTF flag to detect
a time-out. An interrupt will occur if the individual interrupt EWDT (EIE0.4) and global interrupt enable
EA is set. WDT will continue counting. User should clear WDTF and wait for the next overflow by
polling WDTF flag or waiting for the interrupt occurrence.
In some application of low power consumption, the CPU usually stays in Idle mode when nothing
needs to be served to save power consumption. After a while the CPU will be woken up to check if
anything needs to be served at an interval of programmed period implemented by Timer 0~3.
However, the current consumption of Idle mode still keeps at a “mA” level. To further reducing the
current consumption to “uA” level, the CPU should stay in Power-down mode when nothing needs to
be served, and has the ability of waking up at a programmable interval. The MS51 is equipped with
this useful function by WDT waking up. It provides a very low power internal oscillator 10 kHz as the
clock source of the WDT. It is also able to count under Power-down mode and wake CPU up. The
demo code to accomplish this feature is shown below.
ORG 0000H
LJMP START
ORG 0053H
LJMP WDT_ISR
ORG 0100H
;********************************************************************
;WDT interrupt service routine
;********************************************************************
WDT_ISR:
CLR EA
MOV TA,#0AAH
MOV TA,#55H
ANL WDCON,#11011111B ;clear WDT interrupt flag
SETB EA
RETI
;********************************************************************
;Start here
;********************************************************************
START:
MOV TA,#0AAH
MOV TA,#55H
ORL WDCON,#00010111B ;choose interval length and enable WDT
;running during Power-down
SETB EWDT ;enable WDT interrupt
SETB EA
MOV TA,#0AAH
MOV TA,#55H
ORL WDCON,#10000000B ; WDT run
;********************************************************************
;Enter Power-down mode
;********************************************************************
LOOP:
ORL PCON,#02H
LJMP LOOP