The problem

Recently, my wife bought an alarm clock for my daughter. My daughter was playing when she ate in the morning, but she didn’t know how to adjust the time, so she asked me to help. When I adjusted the time, I thought of a problem: how does the computer time work? Why is it that the computer shuts down and then turns on at the correct time, not the exact moment when it shuts down?

lenovo

  1. The clock on the wall ran out and time stopped
  2. The clock ran out and the clock stopped
  3. The watch ran out of juice and time ran out

So although the computer shut down, but the time system did not power, then this time system is what?

The truth

Computer motherboard with clock chip and battery is used to maintain the normal timing clock computer off after, another computer operating system, whether it’s Windows, Linux or MAC OS or any other system (mainstream version), and normal work automatically when the time on the network server to synchronize time setting, Keep time accurate.

There are separate crystal oscillator, separate counter, separate battery power supply to ensure uninterrupted timing.

First of all, there is a clock divider to record the number of rising edges of crystal oscillator waveform. The frequency of rising edges of crystal oscillator waveform is fixed, so the time can be judged by how many rising edges there are. This single crystal frequency is generally 32768Hz, that is, one second passes for every 32768 rising edges. The clock divider will output a time signal to the counter every second.

The value in the counter is increded by one per second based on the output of the divider. This is the number of seconds from 00:00.00 on January 1, 1970 to that time. If the value is 31,536,000, it represents 00:00.00 on January 1, 1971. The software takes the number from the counter and calculates the time.

The clock chip

RTC (Real Time clock) chip, as through the power supply or battery power chip, will produce a fixed frequency pulse, based on such an assumption, can be programmed to run on the BIOS, by calculating the number of pulse to time; A host that is completely offline can set the BIOS time so that the interval is long enough to still report the latest time stably.

RTC real-time Clock

Real-time Clock is the generation pulse of the Clock circuit composed of crystal oscillator and related circuits on the PC motherboard, providing a stable Clock signal for the subsequent circuit. The main functions are: clock, calendar, alarm clock, periodic interrupt output, 32KHz clock output.

An RTC is an integrated circuit, usually called a clock chip.

Real-time clock chip is one of the most widely used consumer electronic products in daily life. It provides accurate real-time time for people, or provides accurate time reference for electronic system. At present, most real-time clock chips use crystal oscillator with high precision as the clock source. Some clock chips require additional battery power in order to work when the main power supply fails.

RTC development history

  1. Early RTC products

The essence of the early RTC product was a frequency divider with a computer communication port. The time information of year, month, day, hour, minute and second can be obtained by dividing and accumulating the oscillation frequency generated by crystal oscillator and sent to processor for processing through computer communication port. The characteristics of RTC in this period are as follows: parallel interface on the control interface line; High power consumption; Using common CMOS process; Package for double in-line; Chips generally do not have the automatic calendar and leap year month switching features of modern RTC, nor can they handle the year 2000 problem. It has now been eliminated.

  1. Intermediate RTC products

In the mid-1990s, a new generation of RTC emerged, which used a special CMOS process; The power consumption is greatly reduced, and the typical value is about 0. 5 mu A the following; The supply voltage is only 1. The following 4 v; And computer communication port has also become a serial way, such as three-line SIO/ four-line SPI, some products use 2-line I2C bus; The package adopts SOP/SSOP package, the volume is greatly reduced; Function: the degree of intelligence in the chip is greatly improved, with perpetual calendar function, output control has become flexible and diverse. Among them, The RTC launched by RICOH of Japan has even appeared the time-base software adjustment function (TTF) and the oscillator stop automatic detection function and the chip price is very low. At present, these chips have been widely used by customers.

  1. Latest generation OF RTC products

The latest generation of RTC products, in addition to contain all the functions of the second generation of products, but also added composite functions, such as low voltage detection, primary and standby battery switching function, printed board leakage resistance function, and its own package is smaller (height 0. 85mm, the area is only 2mm by 2mm).

RTC hardware structure

  1. crystals

Crystal oscillator is generally called Crystal resonator, is a kind of mechanical and electrical devices, Crystal oscillator is short for quartz oscillator, English name Crystal is made of small electrical loss of quartz Crystal by precision cutting grinding and plating electrode welding lead. Role of crystal oscillator: to provide the reference frequency.

  1. RTC crystals

At the heart of any real-time clock is the crystal oscillator, which has a frequency of 32,768 Hz. It provides accurate and low-power real – base signals for the frequency division counter. It can be used to generate information about seconds, minutes, hours, days, etc. To ensure the clock’s long-term accuracy, the crystal oscillator must work properly and cannot be disturbed. RTC crystal oscillator is divided into external crystal oscillator and internal crystal oscillator.

  1. Why is the crystal frequency of RTC 32768Hz?
  • RTC time is calculated in terms of oscillation frequency. So it’s not a timer but a counter. The average counter is 16 bits. And because the accuracy of time is very important, so the lower the number of shocks, the lower the accuracy of time. So it must be a high degree. 215 = 32768.
  • 32768 Hz = 215, namely, 1Hz after 15 frequency division, period = 1s.
  • After summarizing the experience of engineers, 32768 Hz, the clock is the most accurate.
  • Standardization and uniformity.

RTC bus interface

Commonly used clock chips can be divided into parallel interface and serial interface. (Parallel clock chips have high data transmission rate and many connections, which is not conducive to reducing the volume of products and occupy a lot of CPU port resources. The serial clock chip only needs 2-3 I/O interface lines of THE CPU, which can greatly reduce the volume of the product line interface.

RTC clock error

The time error of real-time clock chip is mainly caused by the frequency error of crystal oscillator, which is mainly caused by temperature change. Therefore, it is the key to improve the clock precision to compensate the error caused by temperature to crystal resonant frequency effectively. The quartz crystal resonant frequency error compensation method is based on the crystal resonant frequency with the temperature of the error is known, the generation of 1Hz frequency division counter compensation method.

The most important function of RTC is to provide the calendar function to 2099. For time, no matter how fast or slow is an error, and the matching capacitor plays a very important role in the peripheral devices of RTC, which can properly correct the matching problem between crystal and RTC.