RTC (Real_Time Clock) provides a time reference for the entire electronic system. MCU, MPU, and CPU are inseparable from RTC circuit design. When designing and applying RTC units, delays, timeouts, or excessive power consumption are often found. How to solve the RTC accuracy and power consumption problems? This article will introduce you to the application design of the clock chip PCF8563 and give corresponding solutions.
1. What is RTC?
Real-time clock (Real_Time Clock) is referred to as RTC for short, and it mainly provides a time reference for various electronic systems. Usually, the RTC integrated into the chip is called the on-chip RTC, and the RTC extended outside the chip is called the external RTC. PCF8563 is a low-power CMOS real-time clock/calendar external chip that supports programmable clock output, interrupt output, low-voltage detection, etc. It communicates with the processor through the I2C serial bus, and the bus rate can reach 400kHz.
2. RTC accuracy design
The main responsibility of RTC is to provide an accurate time reference. An RTC with inaccurate timing is worthless. At present, some MCUs have integrated RTC in the chip. In actual tests, the deviation of the RTC in the chip is 1-2 minutes in a battery-powered environment for 6 hours. Therefore, if there are higher requirements for the real-time clock, it is necessary to give priority to the external RTC, and at the same time, the RTC with higher clock accuracy is required, such as PCF8563. Table 1 shows the clock accuracy comparison of different RTCs.
Table 1 Comparison of common RTC clock accuracy
1) Circuit design
The RTC design circuit is simple but not simple. The selection of clock chip, crystal oscillator, circuit design, device placement, impedance control, and PCB routing specifications will all affect the stability of the RTC time base. Figure 1 shows the circuit design of the RTC chip PCF8563.
Figure 1 PCF8563 reference circuit diagram
2) Selection of crystal-to-ground capacitance value
Load capacitance Cload = [ (Ca*Cb)/(Ca+Cb) ]+Cstray, where Ca and Cb are the capacitances connected from the two crystal pins to the ground, and Cstray is the wiring capacitance from the crystal pin to the processor transistor pin (i.e. the total stray capacitance). The typical value of Cstray is generally between 4 and 6pF; if the crystal load capacitance requirement of 12.5pF is to be met, Cload = [ (15*15)/(15+15) ]+5=12.5pF.
Figure 2 Common clock circuit
3) PCB layout
Since the RTC crystal input circuit has a very high input impedance, the connection between it and the crystal is like an antenna, which can easily couple high-frequency interference from other circuits in the system. The interference signal is coupled to the crystal pin, causing the number of clocks to increase or decrease. Considering that the frequency of most signals on the circuit board is higher than 32.768kHz, additional clock pulse counts usually occur. Therefore, the crystal should be placed as close to the OSC1 and OSC2 pins as possible, and the crystal, OSC1 and OSC2 pins should be laid out on the ground plane. The specific PCB layout is shown in Figure 3.
Figure 3 PCB wiring
4) Circuit related instructions
As shown in Figure 1, R56 and R57 are I2C bus pull-up resistors. The interrupt output and clock output of PCF8563 are open-drain outputs, so external pull-up resistors are also required, such as R58 and R59 in Figure 1. If these two signals are not used, the corresponding pull-up resistors can be omitted.
For the PCF8563 chip, an external clock crystal oscillator of 32.768kHz is required (such as X1 in Figure 1). It is recommended to use a crystal oscillator of ±20ppm or more stable. The typical application circuit of PCF8563 recommends the use of a 15pF crystal matching capacitor. In actual application, corresponding adjustments can be made to enable the RTC to obtain a higher-precision clock source. Generally, the crystal matching capacitor is adjusted between 15pF and 21pF (relative to the 32.768kHz crystal oscillator with an accuracy of ±20ppm). The clock frequency is slightly higher when the capacitor is 15pF, and the clock frequency is slightly lower when the capacitor is 21pF.
5) Accuracy adjustment method
1. Set the PCF8563 clock output valid (CLKOUT) and the output frequency to 32.768kHz;
2. Use a high-precision frequency meter to measure the frequency of the CLKOUT output;
3. According to the measured frequency, short or disconnect CB1, CB2, and CB3. When the frequency is higher than 32.768kHz, increase the capacitance value. When the frequency is lower than 32.768kHz, reduce the capacitance value.
Note: The values of C41, C42, and C43 in Figure 1 are between 1pF and 3pF. Determine the combination method according to the actual situation to facilitate quick adjustment. It is recommended to use (3pF, 3pF, 3pF), (1pF, 2pF, 3pF), and (2pF, 3pF, 4pF).
III. RTC low power design
Many RTCs are designed to work with only one battery. If the main power is turned off, only a small lithium battery can drive the oscillator and the entire clock circuit. How to reduce the power consumption of the RTC circuit when it is working?
RTC power consumption can be reduced by applying several different methods:
Choose a low-power RTC, such as PCF8563. Table 2 shows the power consumption comparison of different RTCs.
Table 2 Common RTC power consumption comparison
In the RTC power switching circuit, a diode with small leakage current, such as BAV74, is selected. When the system power supply voltage 3.3V is disconnected, the BT1 lithium battery CR2032 (3V/225mAh) supplies power to the RTC through the diode;
Figure 4 RTC power switching circuit
Access the RTC as little as possible and reasonably to reduce the dynamic current of the I2C bus;
design the pull-up resistor of the I2C bus to be as large as possible, such as 10k;
when applied, turn off the RTC clock CLKOUT output by setting the register.
|