X1226 has the functions of clock and calendar. The clock relies on hour, minute and second registers to track, and the calendar relies on date, week, month and year registers to track. The calendar can correctly pass 2099 and has automatic leap year correction.
It has a powerful dual alarm function that can be set to any clock/calendar value with an accuracy of 1s. The output frequency can be set to any one of 1 Hz, 4096 Hz or 32768Hz by software.
The device provides a backup power input pin VBACK1 to allow the device to be backed up by a battery or a large-capacity capacitor. Many battery types can be used as backup batteries for Xicor's real-time clock device X1226. 3.0V or 3.6V lithium-ion batteries are more suitable and have a service life of 10 years. Another usage can be to choose a large-capacity capacitor. The backup time can last from a few days to two weeks, depending on the size of the capacitor. Use a simple silicon or Schottky diode connected to Vcc and the charging capacitor. The charging capacitor is connected to the Vback pin. Note that the diode cannot be used to charge the battery (especially lithium-ion batteries). The condition for switching to battery power supply is Vcc=Vback-0.1V. During normal operation, the supply voltage Vcc must be higher than the battery voltage, otherwise the battery power will gradually be exhausted.
The crystal required for the oscillator uses an external 32.768kHz crystal. The resulting oscillation error can be corrected by adjusting the values of the digital trimming register and the analog trimming register through software, avoiding the influence of the discreteness of the external resistor and capacitor on the accuracy.
The device can provide 4Kb EEPROM and 8 blocks of lock control. It can be used as a memory for storing a large amount of user data, which is safe and confidential. The data in this memory will not be affected when both the main power supply and the backup power supply fail.
1 Circuit composition and working principle
The real-time clock device X1226 can be interfaced with various types of microcontrollers or microprocessors, and the interface method is a serial I2C interface. The data bus SDA is a bidirectional pin used to input or output data. It is an open-drain output, and a pull-up resistor needs to be added during use, with a resistance value of approximately 4.7Ω to 10kΩ. This article introduces the interface method between the 89C51 microcontroller and X1226. Since the 89C51 microcontroller does not have a standard I2C interface, it can only be simulated by software.
In order to see the time change more intuitively, an eight-bit LED digital tube is used to display the change of year, month, day or hour, minute, and second. The LED digital tube is driven by our company's own product PS7219A, and the digital tube selects a 1.27cm common cathode red or green LED digital tube. Since the PS7219A device contains an IMP810 microcontroller monitoring device, the reset output is valid at a high level, so when using the 51 system, there is no need to add a monitoring device. The reset output of the PS7219A can be used to reset the 51 microcontroller. The monitoring voltage is 4.63V. The hardware design schematic is shown in Figure 1.
During the hardware power-on debugging process, please do not touch the crystal of the real-time clock X1226 with your hands, as this may cause the oscillator to stop oscillating. The way to restore the oscillator is to turn off the power supply (including the backup power supply) and then turn it on again. In addition, it should be noted that when measuring the oscillator, please do not use the oscilloscope probe to measure the oscillation output of X2. The correct method is to use the probe to measure the oscillation output of PHz/IRQ to determine whether it is oscillating and whether the oscillation frequency is accurate. It is recommended to add a 5.1 kΩ pull-up resistor to this pin when measuring.
Note: When designing printed circuits, please refer to the manufacturer's recommended method in the X1226 data sheet for the wiring of xl226.
2 Software Design
X1226 consists of real-time clock register (RTC), status register (SR), control register (CONTROL), alarm register (Alarm0, Alarm1) and customer data storage. Since the real-time clock register (RTC) and status register (SR) need to be written frequently, its storage structure is a volatile SRAM structure, which has no limit on the number of write operations. The other register structures are all non-volatile EEPROM structures, which have a limit on the number of write operations, usually more than 100,000 times. The X1226 initialization program flow is shown in Figure 2.
Start condition subroutine:
SETB SDA
LCALL YS4
SETB SCL
LCALL YS4
CLR SDA
LCALL YS4
CLR SCL
LCALL YS4
RET
Stop condition subroutine:
CLR SDA
LCALL YS4
SETB SCL
LCALL YS4
SETB SDA
RET
Note: The function of subroutine YS4 is to delay 4μs.
2.1 Write operation
After X1226 is initialized, the microcontroller sets the start condition for X1226. Before writing CCR or EEPROM, the host must first write 02H to the status register, confirm the response signal, write 06H after confirmation, and then confirm the response signal. After confirmation, the write operation is started. First send the high address, then send the low address. Xl226 will generate a response signal after receiving each address byte. After both address bytes are received, X1226 waits for 8 bits of data. After receiving 8 bits of data, X1226 generates another response. The microcontroller then terminates the transfer by generating a stop condition.
X1226 has a continuous write function. After receiving each byte, X1226 responds with an acknowledgement and internally increases the address by one. When the counter reaches the end of the page, it automatically "returns" to the first address of the page. This means that the microcontroller can write 64 bytes to the memory array or 8 bytes to the CCR continuously from any position on a page.
Subroutine for writing X1226 data:
MOV R5, #8
SENDI: MOV A, DATASE
RLC A
MOV DATASE, A
MOV SDA, C
SEB SCL
LCALL YS4
CLR SCL
LCALL YS4
DJNZ R5, SENDl
RET
2.2 Read operation
At power-on, the default value of the 16-bit address is 0000H. After the X1226 initialization operation, the microcontroller sets the start condition for X1226. Before writing CCR or EEPROM, the host must first write 02H to the status register, confirm the response signal, write 06H after confirmation, and then confirm the response signal. After confirmation, the write operation is started. First send the high address, then send the low address. Xl226 will generate an acknowledge signal after each address byte received. The microcontroller sends another start condition, sets the R/W bit to 1, and then receives 8 bits of data. When the microcontroller terminates the read operation, it does not need to wait for the response signal of X1226, and the microcontroller can set the stop condition.
Read out X1226 data subroutine:
MOV R5,#8
MOV DATARE,#0
SETR SDA
CLR C
READl:SETB SCL
LCALL YS4
MOV C,SDA
CLR SCL
MOV A,DATARE
RLC A
MOV DATARE,A
LCALL YS4
DJNZ R5,READl
RET
2.2 X1226 unique oscillator frequency online compensation adjustment function
Xicor has integrated an oscillator compensation circuit on the X1226 chip, which allows users to fine-tune the oscillator frequency online through software. This fine-tuning of the oscillator frequency is usually for two situations. One situation is to compensate for the frequency deviation of the oscillator due to the initial accuracy of the device at a normal temperature of 25℃; the second situation is to compensate for the frequency drift caused by temperature. X1226 has a digital trim register (DTR) and an analog trim register (ATR), both of which are non-volatile registers. The digital trim register (DTR) has three digital trim bits with an adjustment range of -30ppm~+30ppm. The analog trim register (ATR) has six analog trim bits with an adjustment range of +116ppm~-37ppm.
In order to compensate for the temperature drift caused by the change of external ambient temperature, a temperature sensor is required to be designed in the system and placed as close as possible to the real-time clock device X1226, so that the temperature of the oscillator can be truly reflected. The schematic diagram is shown in Figure 3. The microcontroller first obtains the ambient temperature through the system temperature sensor, obtains the corresponding compensation value in the compensation parameter table, and then fills the compensation data into the corresponding fine-tuning register to achieve the purpose of temperature drift compensation.
Previous article:VHDL Design of Interface between 8-bit 51 Single-chip Microcomputer and Ethernet Controller RTL8029
Next article:13×14 dot matrix reduced code Chinese card for 51 single chip microcomputer
Recommended ReadingLatest update time:2024-11-17 02:56
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- This year, friends in the RF field, please come and discuss.
- 【National Technology N32G430】Review of lighting up WS2812 lamp
- XMC4800 Review (V) Simple CAN to USB Converter
- 【Silicon Labs BG22-EK4108A Bluetooth Development Review】EFRConnect Mobile Applicationw and Issues
- kicad-age_12-layer_ciaa_acc
- Goodbye 2019, Hello 2020 + Standing at the Crossroads of Life
- Application of FPGA in barcode reader.zip
- 【GD32307E-START】02-Drawing of mechanical dimension drawings
- Xunwei i.MX6ULL Terminator Buildoot file system construction chapter buildroot file system test
- Spectrum Analysis Series: Why do we need a preselector?