Datasheet

ADE7116/ADE7156/ADE7166/ADE7169/ADE7566/ADE7569
Rev. B | Page 121 of 152
REAL-TIME CLOCK (RTC)
The ADE7116/ADE7156/ADE7166/ADE7169/ADE7566/
ADE7569 have an embedded real-time clock (RTC) as shown in
Figure 103. The external 32.768 kHz crystal is used as the clock
source for the RTC. Calibration is provided to compensate the
nominal crystal frequency and for variations in the external
crystal frequency over temperature. By default, the RTC is
maintained active in all power saving modes. The RTC counters
retain their values through watchdog resets and external resets.
They are only reset during a power-on reset.
8-BIT
PRESCALER
SECOND COUNTER
SEC
MINUTE COUNTER
MIN
HOUR COUNTER
HOUR
ITEN
ALARM
EVENT
8-BIT
INTERVAL COUNTER
INTVAL SFR
INTERVAL
TIMEBASE
SELECTION
MUX
RTCEN
32.768kHz
CRYSTAL
ITS1 ITS0
EQUAL?
CALIBRATION
RTCCOMP
TEMPCAL
MIDNIGHT EVENT
CALIBRATED
32.768kHz
06353-077
HUNDREDTHS COUNTER
HTHSEC
Figure 103. RTC Implementation
RTC SFRS
Note that none of the real-time clock SFRs are bit addressable.
Table 127. Real-Time Clock SFR
SFR Address Description
TIMECON 0xA1 RTC Configuration (see Table 128).
HTHSEC 0xA2
Hundredths of a Second Counter
(see Table 129).
SEC 0xA3 Seconds Counter (see Table 130).
MIN 0xA4 Minutes Counter (see Table 131).
HOUR 0xA5 Hours Counter (see Table 132).
INTVAL 0xA6 Alarm Interval (see Table 133).
RTCCOMP 0xF6
RTC Nominal Compensation (see
Table 134).
TEMPCAL 0xF7
RTC Temperature Compensation (see
Table 135).
Protecting the RTC from Runaway Code
To protect the RTC from runaway code, a key must be written
to the KYREG SFR (Address, 0xC1) to obtain write access to the
interrupt pins configuration SFR (INTPR, Address 0xFF),
hundredths of a second counter SFR (HTHSEC, Address 0xA2),
seconds counter SFR (SEC, 0xA3), minutes counter SFR (MIN,
Address 0xA4), and hours counter SFR (HOUR, Address 0xA5).
KYREG should be set to 0xEA to unlock it and reset it to zero
after a timekeeping register is written to. The RTC registers can
be written using the following 8052 assembly code:
MOV KYREG,#0EAh
MOV INTPR,#080h