User`s manual

BL1600130 s Power Management
Sample Program to Handle Power Failure
Z-World recommends the following routine to handle an /NMI. The
routines monitor the state of the /PFO line via U2 and the data bus to
determine if the brownout condition is continuing or if the power has
returned to normal levels. If you use this routine, you will never have to
worry about multiple power-failure /NMIs because this routine simply
never returns from the first /NMI unless the power returns.
main(){
...
}
...
char dummy[24]; // reserve dummy stack
// for /NMI processing
...
#define NMI_BIT 6 // routine will test data
// bit 6 to determine
// state of /NMI line
#JUMP
_
VEC NMI
_
VEC myint
#asm
myint::
ld sp,dummy+24 ; force stack pointer
; to top of "dummy"
; array to prevent
; overwriting of code
; or data
do whatever service, within allowable execution time
loop:
call hitwd ; make sure no
; watchdog reset
; during brownout
ld bc,NMI ; load the read-NMI
; register to bc
in a,(c) ; read the read-NMI
; register to /PFO
bit NMI_BIT, a ; check /PFO status
jr z,loop ; wait until brownout
; condition clears
timeout: ; then... a tight loop
; to force a watchdog
; timeout
jp timeout ; which will reset the
; Z180
#endasm