Clock chip RTC principle introduction, crystal oscillator selection, application scenarios

  [Little knowledge] Clock chip is a high-performance, low-power, real-time clock circuit with RAM. The English name is: Real-time Clock/Calendar Chip (abbreviated as: RTC). It can time the year, month, day, weekday, hour, minute, and second, and has leap year compensation function. It uses IIC communication interface.

> Principle of clock chip
· Analysis of the working principle of clock chip

I. Basic structure of clock chip
The clock chip is a microcontroller with integrated timing function. Its basic structure includes input/output port, timer/counter, interrupt controller, etc. Among them, the input/output port is used to receive external signals, the timer/counter is used to generate time reference, and the interrupt controller is used to handle the overflow event of the timer.

II. Working principle of clock chip
1、Input/output port
The clock chip can receive external signals through the input/output port to adjust the system time as needed. For example, receive clock information of a computer or other device through a serial communication interface (UART, I2C, SPI, etc.), or synchronize network time through a network interface (such as NTP).
2、Timer/Counter
The clock chip usually integrates one or more timers/counters to generate a time base. The working mode of the timer/counter is realized through a prescaler and a counter. The prescaler reduces the system clock frequency to the appropriate counter clock frequency, and the counter is used to calculate the elapsed time. When the count value of the timer/counter reaches the set value, an interrupt event will be triggered to notify the system to update the time.
3、Interrupt Controller
In order to handle the overflow event of the timer, the clock chip also has an interrupt controller. When the count value of the timer/counter reaches the set value, an interrupt request will be sent to the interrupt controller. The interrupt controller will recognize this request and execute the corresponding interrupt service routine (ISR), such as updating the system time, waking up the task waiting to be processed, etc.
4、Update of system time
When the system time changes, the clock chip needs to perform a series of operations to update the system time. First, receive new clock information through the input/output port; then, use the timer/counter to calculate the time difference; then, add the calculated time difference to the current system time; finally, notify other parts of the system time that the update has been made through the interrupt controller.

> The connection between clock chip and crystal oscillator
· Why is the clock crystal oscillator frequency commonly used in the circuit design of clock chip 32.768kHz?
Because the clock chip needs to calculate the time accurately, and 32.768khz is easier to divide (1hz is converted to 1s), so as to generate a clock frequency of 1 second, so it has become the best partner for the clock chip. The clocks displayed on watches, mobile phones and computers that we use every day are evolved from it.


32.768KHz is a standard frequency, with the following parameters: size, load capacitance, frequency deviation, and application range. According to the size, it is mainly divided into 2012/3215; there are many models available according to the design of each company.
In the clock system, the second is an important time unit, and 1 second is exactly 1hz. If you want to improve the time accuracy, then this 1hz must be accurate. We know that in the digital world, there are only two possibilities: 0 and 1. Let's take a look at a calculation:
2^15=32768=32.768K
The 15th power of 2 is exactly equal to 32768. Conversely, if the clock frequency of 32.768khz is divided 15 times, the resulting frequency is exactly 1Hz.

> Clock chip application scenarios
· Clock chips are widely used in communication equipment, consumer electronics, industrial control, automotive electronics, Internet of Things and smart home, providing accurate clock synchronization and timing functions for various electronic systems. The YXC product series can replace most foreign brands in P2P under the condition of consistent parameters.

Application scenarios
· Security monitoring system: Provide time identification for functions such as alarm, search and return visit, and time synchronization between nodes.
· Smart office: attendance machine, access control system and other occasions that require accurate time recording.
· Server and network equipment: record equipment work logs for equipment management and fault location.
· Consumer electronics: Provide time display and alarm functions in digital cameras, MP3 players, electronic watches and other devices.
· Smart home: Time control of home appliances to achieve energy management.
· Internet of Things devices: Ensure accurate operation of equipment and accurate data recording.

YXC Real-time Clock (RTC) Product Portfolio

1. High-precision RTC with temperature compensation function. Excellent stability within the operating temperature range, with an accuracy of +-3.4ppm@-40~85℃.

2. Low-power RTC. Low current consumption (typical value is 250nA).

3. Small-volume RTC. The package size is 3.2*2.5mm, suitable for miniaturized devices.

4. Separate RTC. The design scheme is more flexible.