
μ
PD17016, 17017
153
13.6.2 Notes on detecting power failure by BTM0CY flag
The following points must be noted when using the BTM0CY flag for watch counting.
(1) Updating watch
When developing a watch program by using the timer carry, the watch must be updated after a power
failure has been detected.
This is because counting of the watch is skipped once because the BTM0CY flag is reset to “0” when
the BTM0CY flag is read on detection of a power failure.
(2) Watch updating processing time
The processing to update the watch must be completed before the next timer carry FF setting pulse rises.
This is because, if the CE pin goes high during the watch updating processing, CE reset is effected without
the watch updating processing completed.
For further information on (1) and (2) above, refer to
11.3.7 (b) Correction of timer carry on CE reset
.
When detecting a power failure, the following points must be noted.
(3) Timing of power failure detection
To count the watch by using the BTM0CY flag, the BTM0CY flag must be read to detect a power failure
within the time since the program has started from address 0000H until the next timer carry FF setting
pulse rises.
For example if the timer carry FF setting time is set to 5 ms, and a power failure is detected 6 ms after
the program has been started, the BTM0CY flag is overlooked once.
For details, refer to
11.3.7 (b) Correction of timer carry on CE reset
.
Power failure detection and initial processing must be completed within the timer carry FF setting time
as shown in the following example.
This is because, if the CE pin goes high and CE reset is effected during power failure detection processing
and initial processing, these processing may be stopped in midway, and thus problems may occur.
To change the timer carry FF setting time by the initial processing, the instruction that changes the time
must be executed at the end of the initial processing, and the instruction must be one instruction.
This is because the initial processing may not be completely executed because of CE reset if the timer
carry FF setting time is changed before the initial processing is executed, as shown in the following
example.