Computer

You know that your PC has a real time clock, but how does it work?

The internal real-time clock of the PC has a utility that goes far beyond showing you the time on 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 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 their many chips) that is built for 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 embedded systems, servers and any electronic component that has a processor, since these elements require a accurate stopwatch for its operation as we will explain shortly. Being able to continue working even when the PC is turned off or with a battery is essential, which is why in general they usually carry a battery in CR1220 or CR2032 format which 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 which, when removed, resets the RTC to its starting point (and you have to go back to set the system time).

RTC module

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 system processes are in sync properly, something 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 diagram

The real-time clock information can be read by a microprocessor, usually through a serial interface to make it easier for 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 usually connected to the CPU using a SPI or I2C serial bus, and may contain a number of other functions such as memory backup, a watchdog timer to monitor processor operation, or countdown timers to generate events in real time. Some RTCs include second or minute interrupt outputs and are smart and autonomous enough to account for leap years.

RTC scheme

A real-time clock keeps its time by counting the cycles of a oscillator, generally made of quartz crystal and that operates 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 that is executed from its own internal reference, will integrate a error range related to the absolute accuracy of the crystal reference and will be affected by a number of conditions, including the 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.

RTC crystal precision

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 obtains an updated system time and writes this new value constantly to the RTC to avoid these deviations, that is, that the CPU is constantly recalibrating the RTC to always keep it accurate.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *