This information can be read by a microprocessor, usually over a serial interface to facilitate the software performing functions that are time dependent. RTCs are designed for ultra-low power consumption as they usually continue running when the main system is powered down. This enables them to maintain current time against an absolute time reference, usually set by the microprocessor directly. Figure 1 depicts the typical internal workings of a simple RTC.
RTCs are a very common element. They are present in everything from the instrument clusters and infotainment systems in automotive applications to house metering. RTCs frequently integrate into other devices—for example, the broadband communications ICs used in car radios.
They usually interface to a microprocessor circuit by an SPI or I2C serial bus, and may contain a number of other functions like backup memory, a watchdog timer for supervising the microprocessor and countdown timers to generate real time event. Some RTCs include second or minute interrupt outputs and are even clever enough to account for leap years (see figure 2).
An RTC maintains its clock by counting the cycles of an oscillator – usually an external 32.768kHz crystal oscillator circuit, an internal capacitor based oscillator, or even an embedded quartz crystal. Some can detect transitions and count the periodicity of an input that may be connected.
This can enable an RTC to sense the 50/60Hz ripple on a mains power supply, or detect and accumulate transitions coming from a GPS unit epoch tick. An RTC that does this operates like a phase locked loop (PLL), shifting its internal clock reference to ‘lock’ it onto the external signal. If the RTC loses its external reference, it can detect this event (as its PLL goes out of lock) and free run from its internal oscillator.
Some RTCs maintain the oscillator setting at the last known point before it went out of lock with the input. Time resolution is an important consideration – how accurately do you need to read the current time? This is specified by the RTC datasheet, but is ultimately limited by the oscillator frequency.
An RTC that is running from its own internal reference will integrate an error related to the absolute accuracy of the crystal reference, and is effected by a number of conditions including temperature. Crystals are specified to operate within a temperature range, usually around -10°C ~ 60°C – and their accuracy is reduced if a design deviates outside this (figure 3).
Some RTCs have integrated temperature compensation that can extend and increase the accuracy of the crystal oscillator circuit. Crystals also age, and this changes their physical nature, which leads to additional errors. Typical low cost crystals have frequency tolerance of around +/-20ppm (parts per million), and slowly accumulate errors. A +/-20ppm crystal could drift as far as 72mS every hour, or 1.7 seconds per day. They occasionally require recalibration to correct for the drift.
The connected processor obtains an updated ‘system time’ in some way and writes this new value to the RTC for it to start counting from. This system time could come from manual input from a user interface, reading a GPS unit or from a cloud connection.
RTCs need continuous power and must have extremely low power consumption. Most RTCs use the digital circuits supply when the device is on and active, but switch over to a continuously connected power source when the circuit is powered down. This power source could be a dedicated battery, a charged supercapacitor or a separate power supply from mains.
Many RTCs can detect this change-over and go into an ultra-low power state where they power down all circuitry except those essential for maintaining the clock in order to conserve battery life. RTCs can also include alarm functions – set times that when reached trigger the RTC to drive an output that wakes the processor up.