cd00003995

AN923
Application note
Managing century information using serial real-time clocks and
TIMEKEEPER® NVRAMs
By Doug Sams
Introduction
®
ST's serial real-time clocks (RTCs) and TIMEKEEPER NVRAMs all include at least one byte of year
data in binary-coded decimal (BCD) format. Many devices include additional bits for tracking the
century, effectively extending the year register. Applications can use software to further extend the
century/year data to any desired resolution. The amount of software required depends on the resources
built into the chip and the resolution needed by the application.
January 2015
DocID005227 Rev 4
1/9
www.st.com
Devices with no century data
1
AN923
Devices with no century data
M48T02/12, M48T08/08Y/18
A few devices have only a single byte of year information. The BCD year register
represents a 2-digit number in the range 00 to 99. The result is that the software must
interpret what the 2-digit number means. For example, 85 might be interpreted as 1985, or
2085, or 2185. So the software must maintain the upper two digits of the year, outside of
the RTC.
The reader should note that the upper two digits of the 4-digit year are considered the
century value. So, for the devices listed above, the software must maintain the century
information in non-volatile memory such as flash or EEPROM, and increment the century
value whenever the year value, in the RTC, rolls over from 99 to 00.
2/9
DocID005227 Rev 4
AN923
2
Devices with one bit of century data
Devices with one bit of century data
M41ST85W, M41T0, M41T00, M41T00AUD, M41T00CAP, M41T00S, M41T11, M41T56,
M41T80, M41T81, M41T81S, M41T94, M48T35AV, M48T35/Y, M48T58
Most ST clock devices include at least one bit of century information. When enabled (CEB
is set), the century bit will toggle at the end of every century, at midnight of December 31 of
the year ending in 99. User software must interpret the bit's meaning. For example, users
can let 0 represent 2000-2099 and 1 represent 2100-2199, but other mappings may also
be used. By adding more bits in software, the century information can be extended to
whatever resolution is desired.
DocID005227 Rev 4
3/9
Devices with two bits of century data
3
AN923
Devices with two bits of century data
M41ST87W, M41T60, M41T62, M41T63, M41T64, M41T65, M41T66, M41T82, M41T83,
M41T93
Many of ST's newer RTCs include 2 century bits (CB1, CB0) which function as a 2-bit
binary counter that increments at the end of each century. The user may arbitrarily assign
the meaning of CB1:CB0 to represent any century value, but the simplest way of using
these bits is to extend the year register by mapping them directly to bits 9 and 8 (with the
year register comprising bits 7:0). Higher order century bits can be maintained in the
application software.
Figure 1: Two-bit binary counter (century bits CB1:CB0)
Example: 16-bit year value
MAINTAIN�
ADDITIONAL
YEAR BITS IN
SOFTWARE
LOWER 8 BITS
CONTAINED IN
YEAR REGISTER
(07h)
00
01
11
10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CB1
CB0
Century
2000 -2099
2100 - 2199
2200 - 2299
2300 - 2399
D15
D14
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
CB1:CB0
00
01
10
11
CB1:CB0
LET CB1:CB0 REPRESENT
BITS 9 AND 8 TO EXTEND
THE YEAR REGISTER
In this example, CB1:CB0 represent the two lower bits of the century byte.
4/9
DocID005227 Rev 4
AN923
4
Devices with a full byte of century data
Devices with a full byte of century data
M48T201V/Y, M48T37V/Y
Lastly, a few ST TIMEKEEPER devices include a full byte of century information. In
addition to the byte of year data, there is another, upper byte for the century, thus
comprising a full 4-digit (16-bit BCD) year parameter. These devices will automatically track
the century through the year 9999. However, to go beyond that, user software would still
need to add a bit to support the years 10000-19999.
The following table summarizes the type of century data provided by the various ST RTC
and TIMEKEEPER devices.
DocID005227 Rev 4
5/9
Devices with a full byte of century data
AN923
Table 1: Century data provided according to device
Device
Century support
Byte
(1)
CB1/CB0 (2)
CEB/CB (3)
●
M41ST87W
M41T0
●
M41T00
●
M41T00AUD
●
M41T00CAP
●
M41T00S
●
M41T11
●
M41T56
●
M41T60
●
M41T62
●
M41T63
●
M41T64
●
M41T65
●
M41T66
●
Serial RTCs
M41T80
●
M41T81
●
M41T81S
●
M41T82
●
M41T83
●
M41T93
●
●
M41T94
●
TIMEKEEPER supervisor
M48T02/12
●
M48T08/08Y/18
●
M48T35/Y
●
M48T35AV
●
M48T37V/Y
●
●
M48T58
Notes:
(1)
(2)
(3)
(4)
6/9
Product family
●
M41ST85W
M48T201V/Y
None (4)
1 byte (BCD) which increments once per century
2 century bits which increment once per century
1 century bit which toggles once per century
No century information
DocID005227 Rev 4
TIMEKEEPER NVRAM
AN923
5
Support for leap year
Support for leap year
Leap year occurs every four years, in years which are multiples of 4. For example, 2012
was a leap year. An exception to that is any year which is a multiple of 100. For example,
the year 2100 is not a leap year. A contradiction to that is that years which are multiples of
400 are indeed leap years. Hence, while 2100 is not a leap year, 2400 is.
During any year which is a multiple of 4, ST RTC and TIMEKEEPER devices will
automatically insert leap day, February 29. Therefore, the application software must correct
for this during the exception years (2100, 2200, etc.) as noted above.
For more information about ST's TIMEKEEPER NVRAM's and serial real-time clocks,
please contact a local ST sales office or visit www.st.com.
DocID005227 Rev 4
7/9
Revision history
6
AN923
Revision history
Table 2: Document revision history
Date
Revision
Changes
May-2000
1
Initial release
08-Apr-2013
2
Updated title, updated devices in Table 1: "Century
data provided according to device", removed
obsolete contact information
8/9
14-Aug-2013
3
Complete rewrite of document
07-Jan-2015
4
Removed M41TC8025 device from document
DocID005227 Rev 4
AN923
IMPORTANT NOTICE – PLEASE READ CAREFULLY
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications,
and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant
information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at
the time of order acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application
assistance or the design of Purchasers’ products.
No license, express or implied, to any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such
product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
© 2015 STMicroelectronics – All rights reserved
DocID005227 Rev 4
9/9