CMOS RAM

and

Real Time Clock

What is Real Time Clock ?
CMOS RAM/ Real Time Clock Addresses
How BIOS and DOS works with RTC/CMOS in PC systems
How to address and read CMOS/RTC
Test BIOS for Year 2000 compliance


What is Real Time Clock ?

A figure of CMOS RAM + Real Time Clock is shown below. Real Time Clock and CMOS RAM are often contained in the same physical chip. The most common Real-Time Clock + CMOS chip widely used in most PCs is from Motorola's MC146818 or compatible.

The CMOS RAM is a special type of computer memory which consumes very few power. It is typically used for storing PC's configuration such that the operating system can aware what kinds of equipments such as hard disk, memory size that are included in the PC system at boot up. The Real Time clock keeps track of the current date and time. The date and time reported from Real-Time Clock is stored in CMOS RAM as well.

In a PC, the Real Time Clock + CMOS RAM part is powered by a separate battery. They are the only devices in most computer systems that require the use of a battery to provide continous power. With battery backup, the Real Time Clock can still keep track of date and time whereas the CMOS ram can holds the configuration data even the power of a PC is turned off. The power consumption of CMOS RAM and Real Time Clock is very low, the lifetime of battery is determined by its own self-discharge time which is about three years (with lithium batteries up to ten years).


Figure : Technical structure of the MC146818. The MC146818 has a real-time clock and 64 bytes of battery-buffered CMOS RAM

CMOS RAM/ Real Time Clock Addresses

CMOS RAM consists of 64 bytes. The table below shows some of the important addresses being used, which have direct relation to the problem of Y2K.
 
Byte Address Contents
0 00h second *
2 02h minute *
4 04h hour *
6 06h day of week *
7 07h day of month *
8 08h month *
9 09h year *
50 32h century *
* using binary coded decimal (BCD 1 byte)

For every second, the Real-Time Clock updates the above 0,2,4,6,7,8 and 9 byte except century byte. The reason for it is that the Real Time Clock/CMOS chips manufacturers do not aware the problem of Year 2000 problem at the time that they designed their chips which was around 20 years ago. With such, they only use 2 digit year representation (1 byte using BCD code which can hold 2 digit year). Therefore, in the data sheets of their chips, they do not defined the 50th century byte. With such limitation, when the year move from 1999 to 2000, the century byte and year byte of Real time Clock/CMOS will store 19 and 00 respectively and this problem is commonly named as "Rollover problem of Real Time Clock".

This century byte is later pre-defined by some BIOS manufacturers such that 4-digit year is used so as to cater for the problem of Real Time Clock for Year 2000 issue. With such workaround, Real Time Clock/CMOS can then be used to store 4-digit year.

How BIOS and DOS works with RTC/CMOS in PC systems

At boot process, the BIOS (Basic Output/Input System) of PC reads the Real Time Clock/CMOS RAM once so as to determines the current PC configuration (including hard disk size, memory size ... etc) as well as time and date. The date and time values will be passed to DOS, which then sets its own date and time counts to match. After the system has been boot up, DOS will no longer read the real time clock any more and DOS will use another interval timer to count time and date. Only when user manually use DATE and TIME command under DOS to set to other date or time, DOS will then change the corresponding bytes inside CMOS immediately.

How to address and read CMOS/RTC

The CMOS RAM and the real time clock are unusual in the way they are addressed. In this case, a direct address is not used. Instead, the address in the CMOS RAM or real time clock must first be written to the I/O port 70h, then the data at that address can be read or written through I/O port 71h.

The easiest way to read the content of CMOS/RTC is to use DEBUG of DOS. Detail procedure is as listed :

With the above procedures are followed, we will see the following on the display :

DEBUG
- O 70 32
- I 71
19

The figure "19" above means that the century byte is storing binary coded decimal 19 which mean 20th century.Type "Quit" to exit the program DEBUG.

Test BIOS for Year 2000 compliance

As seen from above, the CMOS/Real Time Clock can use 4 digit year but unfortunately, the Real Time Clock do not make use of the century byte. Therefore, during rollover test of Real Time Clock, the century byte will not change from 19 to 20 automatically during the rollover moment from 31-Dec-1999 23:59:59 to 1-Jan-2000 00:00:00. Some older BIOS do not make use of the century byte as well and so these BIOS are not Y2K compliance. To solve the problem, some BIOS has been modified such that they support century byte (i.e. they use 4-digit year). During boot up process, when a Y2K compliance BIOS detects the content of year byte and century byte in CMOS RAM is 00 and 19 respectively, as it is a invalid year, Y2K compliance BIOS will change the century byte content to 20. With such, DOS or other applications will read the current year as 2000 instead of 1900.

Since CMOS/RTC can store 4-digit year, so during Set Test of Real Time Clock, that is manully use DATE command of DOS to enter the year as 2000 to the Real Time Clock, there is no problem for such.

Therefore, to test whether a PC hardware is Y2K compliance or not, we can just test the BIOS of the system. A BIOS is Y2K compliance or not depends on its capability to set the century byte from 19 to 20 when the year reach 2000.

Please click HERE to see how to check BIOS for Year 2000 Compliance.