Real Time Clock or RTC: How Does This Hardware Work

Real Time Clock or RTC

Any fan of electronics or computing knows that the PCs that we use every day are equipped with a real-time clock , and that thanks to the battery that the motherboards integrate, that clock is always on time even when the PC is disconnected from the mains. stream. But, have you ever wondered how it works and, especially, what is the use of the PC having this internal clock?

The internal real-time clock of the PC has a utility that goes far beyond showing you the time in the taskbar, and that is, as we are going to literally explain below, the PC could not function without it. Why? We will explain it to you in depth immediately, but as a preview we will tell you that without this clock the PC processor would not know when it has to do the calculations.

What is a real time clock or RTC and what is it for?

RTC

A real time clock, also known as RTC for its acronym in English ” real time clock “, is a computer clock, usually in the form of an integrated circuit (on motherboards it is just one of its many chips) that is built with the sole objective of keeping time. Naturally, it counts hours, minutes, seconds, months, days, and even years.

The RTCs can be found both in computers (desktop and laptop) as well as in integrated systems, servers and any electronic component that has a processor, since these elements require a precise chronometer for their operation as we will explain shortly. Being able to continue working even when the PC is turned off or if the battery is off is essential, which is why in general they usually carry a battery in CR1220 or CR2032 format that guarantees independent operation for years.

Your PC’s real-time clock must be able to accurately keep time even when the device is turned off, as it is often used as a trigger to turn on the device or to trigger events such as alarm clocks. The integrated circuits of older systems use lithium batteries, while some modern devices make use of auxiliary batteries (such as the battery we have mentioned) or even supercapacitors for this. RTC ICs that use supercapacitors are rechargeable and can be soldered if you like, but as we have mentioned today most use a battery that, when removed, resets the RTC to its starting point (and you have to go back to set the system time).

Módulo RTC

RTC ICs regulate time with the use of a crystal oscillator, so they do not depend on clock signals like most hardware clocks (like the CPU, which depends on this real time clock). In addition to being responsible for the timing function of the system and its clock, the real-time clock ensures that all processes in the system are properly synchronized, which is essential for the operation of the CPU. Although some may argue that this is a job of the internal system clock, it actually depends on the RTC.

The benefits of using RTC on a PC include:

  • RTC ICs have proven to be more necessary than other methods, such as programming the controller timer.
  • It frees the main system from critical timing tasks.
  • It has low power consumption and almost perfect frequency stability, even with low battery.

How does an RTC work on the PC?

RTC diagrama

The real-time clock information can be read by a microprocessor , usually through a serial interface to facilitate the software or firmware to perform time-dependent functions. The processor synchronizes the system time with the RTC in an absolute time reference and, without being like an atomic clock, it has practically no deviation whatsoever, which allows the CPU to perform exact calculations. In the image above you can see the operation diagram of a simple RTC module.

The RTC is typically connected to the CPU via an SPI or I2C serial bus , and can contain a number of other functions such as backup memory, a watchdog timer to monitor processor operation, or countdown timers to generate real-time events . Some RTCs include second or minute interrupt outputs and are smart and self-contained enough to account for leap years .

Esquema RTC

A real-time clock keeps its time by counting the cycles of an oscillator , usually made of quartz crystal and running at 32.768 KHz . This allows an RTC to detect 50/60 Hz ripple from a power source, or to detect and accumulate transitions from a GPS unit tick. An RTC that does this works like a phase-locked loop (PLL), changing its internal clock reference to “lock” it on the external signal. If the RTC loses its external reference, it can detect this event again (since the PLL comes out of lock) and work autonomously with its internal oscillator.

An RTC running from its own internal reference will integrate a margin of error related to the absolute accuracy of the crystal reference and will be affected by a number of conditions, including temperature . The crystals are designed to operate within a temperature range of -10ºC to 60ºC, and their accuracy is reduced if the temperature deviates from this range.

Precisión cristal RTC

Some RTCs have a built-in temperature compensation that can extend and increase the precision of the quartz oscillator. Crystals also age, and this changes their physical nature so that over time they lose precision. Typical low cost crystals used in PC hardware have a frequency tolerance of +/- 20 ppm (parts per million). This means that a crystal with this margin of error could drift up to 72 ms per hour, or 1.7 seconds per day, so they will occasionally require calibration.

The processor connected to the RTC gets an updated system time and writes this new value constantly to the RTC to avoid these deviations, that is, the CPU is constantly recalibrating the RTC to always keep it accurate.