The DS1302 is a low-power real-time clock chip with a fine current charging capability introduced by DALLAS, USA. It can time the year, month, day, week, hour, minute and second, and has many functions such as leap year compensation.
DS1302 main performance indicators:1, DS1302 is a real-time clock chip, can provide seconds, minutes, hours, dates, months, years and other information, and also the ability to automatically adjust the software, you can configure AM / PM to determine whether to use 24-hour format or 12-hour format .
2. Has 31 bytes of data storage RAM.
3, serial I / O communication mode, relatively parallel to save the use of IO port.
4, DS1302's working voltage is relatively wide, probably 2.0V ~ 5.5V can work normally.
5, DS1302 clock chip power consumption is generally very low, it works at a voltage of 2.0V, the operating current is less than 300nA.
6, DS1302 has 8 pins, there are two kinds of package, one is DIP-8 package, chip width (without pins) is 300mil, one is SOP-8 package, there are two widths, one is 150mil, one is 208mil.
7. When the power supply voltage is 5V, it is compatible with the standard TTL level standard. The meaning here is that it can communicate with the MCU perfectly.
8. Since the DS1302 is an upgraded version of the DS1202, all functions are compatible with the DS1202. In addition, the DS1302 has two power inputs, one is the main power supply, and the other is the backup power supply. For example, a battery or a large capacitor can be used. In order to ensure that the system is powered down, our clock will continue to go. If you are using a rechargeable battery, you can also set the charging function to charge our spare battery during normal operation.
DS1302 pin function
1 pin VCC2 is the main power positive pin, 2 pin X1 and 3 pin X2 is the crystal oscillator input and output pin, 4 pin GND is the negative pole, 5 pin CE is the enable pin, connected to the IO port of the MCU, 6 pin I /O is the data transmission pin, connected to the IO port of the microcontroller, the 7-pin SCLK is the communication clock pin, connected to the IO port of the microcontroller, and the 8-pin VCC1 is the standby power supply pin.
   If you connect a 10uF capacitor to the 8th pin, you can run it for about 1 minute after the test. If you want to run longer, you can increase the capacity of the capacitor. The circuit diagram is as follows:
One of the key points of the DS1302's circuit is the clock circuit. The crystal oscillator used is a 32.768k crystal oscillator. There is no need to add additional capacitors or resistor circuits to the outside of the crystal oscillator. The accuracy of the clock depends first on the accuracy of the crystal and the pin load capacitance of the crystal. If the crystal is not accurate or the load capacitance is too small, the clock error will be too large. After all this is done, the final consideration is the temperature drift of the crystal. As the temperature changes, the crystal often changes its accuracy. Therefore, in the actual system, one of the methods is to proofread frequently. For example, the clock of the computer we use, usually we will set an option "set the computer to internet time synchronization". After selecting this option, it is generally possible for some time, our computer will synchronize with the internet time calibration.
Ds1302 related article: 51 single-chip DS1302 real-time clock driver
Shenzhen GEME electronics Co,.Ltd , https://www.gemesz.com