User`s manual

PK2100
C-2 s Power Management
Power Failure Interrupts
The following events occur when power fails:
1. The power-failure nonmaskable interrupt (NMI) is triggered when the
unregulated D.C. input voltage falls below approximately 15.6volts,
or 7.8volts for the PK2110/PK2130 (subject to the voltage divider
R9/R33).
2. The system reset is triggered when the regulated +5-volt supply falls
below 4.5 volts. The reset remains enabled as the voltage falls further.
At this point, the chip select for the SRAM is forced high (standby
mode). The time/date clock and SRAM are switched to the lithium
backup battery as the regulated voltage falls below the battery voltage
of approximately 3 volts.
The following function shows how to handle a power-failure interrupt.
#JUMP_VEC NMI_VEC myint
interrupt retn myint(){
Enter code here to save some variables or tag some flags.
while(!(inport(DREG1)& 0x02));
// wait while NMI line is low
// this means input voltage is still below
// threshold that triggered the NMI
return; // if just a power glitch, return
}
Normally, a power-failure interrupt routine will not return, but will
execute shutdown code and then enter a loop until the power-supply
voltage falls low enough to trigger a reset. However, the voltage in a
brownout situation might fall low enough to trigger a power-failure
interrupt, but not low enough to reset, resulting in an endless hang-up. If
an NMI is encountered, the service routine can monitor bit 1 of DREG1 to
see whether the D.C. input voltage is still below the threshold of 15.6 volts
(bit 1 is 0 if NMI is still active). If the low power was just a glitch, a
return will resume execution of the program. If a lowbut not fatally
lowvoltage persists, then the user has to decide manually what action to
take, if any.
A situation similar to a brownout will occur if the power supply is
overloaded. For example, when an LED is turned on, the voltage supplied
to the Z180 may dip below 15.6 volts. The interrupt routine will execute a
shutdown. This turns off the LED, clearing the problem. However, the
cause of the overload may persist, and the system will oscillate, alternately
experiencing an overload and then resetting. A larger power supply
should correct this situation.