The internal real time clock of the PC has a utility that goes far beyond showing you the time on the taskbar, and as we are going to explain below literally the PC could not work without it. Why? We’ll explain it in depth in a moment, but as a preview we’ll tell you that without this clock the PC processor wouldn’t 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 purpose of keeping time. Naturally, it counts hours, minutes, seconds, months, days and even years.

RTCs can be found in computers (desktop and laptop) as well as in embedded systems, servers and any electronic component that has a processor, as these elements require an accurate timer to function as we will explain shortly. Being able to continue working even when the PC is off or without battery is something fundamental, which is why 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 keep accurate 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. ICs in older systems use lithium batteries, while some modern devices make use of auxiliary batteries (such as the battery we mentioned) or even supercapacitors for this. RTC ICs that use supercapacitors are rechargeable and can be soldered if desired, but as mentioned above, most now use a battery which, when removed, resets the RTC to its starting point (and the system has to be reset).

Módulo RTC

RTC ICs regulate time with the use of a crystal oscillator, so they do not rely on clock signals like most hardware clocks (such as the CPU, which relies 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 system processes are properly synchronized, which is paramount to the operation of the CPU. While some may argue that this is the job of the system’s internal clock, it is actually dependent on the RTC.

The benefits of using RTC in 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 the time and effort required to program the controller’s timer.critical timing calculation areas.
  • It has low power consumption and virtually perfect frequency stability, even with a 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 enable the software or firmware to perform time-dependent functions. The processor synchronizes the system time with the RTC to an absolute time reference and, while not an atomic clock, is virtually drift-free, allowing the CPU to perform accurate calculations. In the image above you can see the operation diagram of a simple RTC module.

Typically, the RTC is connected to the CPU via an SPI or I2C serial bus, and may 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 intelligent and self-contained enough to account for leap years

.

Esquema RTC

A real-time clock keeps time by counting the cycles of an oscillator, usually made of quartz crystal and operating at 32,768 KHz. This allows an RTC to detect the 50/60 Hz ripple of a power supply, or to detect and accumulate transients from a tick of a GPS unit. An RTC that does this functions as a phase-locked loop (PLL), changing its internal clock reference to “lock” to the external signal. If the RTC loses its external reference, it can detect this event again (as the PLL comes out of lock) and run 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. 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 built-in temperature compensation that can extend and increase the accuracy of the quartz oscillator. Crystals also age, and this changes their physical nature so they lose accuracy over time. 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 shift up to 72 ms per hour, or 1.7 seconds per day, so they will occasionally require calibration.

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