1. Overview
With the development of single-chip microcomputer technology, single-chip microcomputers are increasingly used in the field of electromechanical products. On the one hand, it is hoped that the embedded system composed of single-chip microcomputers is as powerful as possible, with strong processing capabilities and many control objects; on the other hand, it is hoped that the cost of the entire system is as low as possible, that is, it has a good cost performance. Therefore, in practical applications, it is often encountered that the I/0 interface resources of the single-chip microcomputer are insufficient. In some more complex application systems, due to the large number of controlled objects, such as controlling the display of multiple LED digital tubes and the display of more than 30 status channels, the contradiction between port supply and demand is particularly prominent. The usual solution is to use external I/0 interfaces such as 8155, 8255, 8259, 74HC164, 74HC165, 74LS373 and 74LS245, which will inevitably make the system more complex, increase costs and reduce reliability.
At present, most of the powerful single-chip microcomputers use FLASH technology, and add advanced and practical functions such as SPI, I2C, CAN, etc. on the basis of the traditional USART serial communication function; and many peripheral chips have communication interfaces such as I2C, such as the ZLG7290 chip with 64 buttons and 8×8 LED digital tube drivers. Therefore, the single-chip microcomputer port expansion can choose a more convenient and more powerful expansion method.
The I2C (Inter-IC, IC TO IC) bus was developed by Philips Semiconductors in the mid-1980s and was originally used for audio and video purposes. After I2C was expanded to the system management bus SMBus, it can be used for power management and communication between the CPU and other components. I2C supports multi-master mode. The transmission rate specified in version 2.1 is up to 100kbit/s in standard mode, 400kbit/s in fast mode, and 3.4Mbit/s in high-speed mode[1]. Since only two port pins of the microcontroller are needed to transmit data of arbitrary characteristics, the I2C bus protocol has been widely used and has promoted the development of a large number of I2C external chips. The I2C bus can be used to control IC cards, data conversion[2], LCD control, clock control[3], memory control[4], multi-machine communication[5], etc. This article mainly discusses the control problem of the ZLG7290 chip based on the I2C interface when MICROCHIP's PIC18F458 is used to control the car body status display.
2. I2C bus working sequence
The serial bus I2C consists of a data line SDA and a clock line SCL. The device connected to the I2C bus can be a master (responsible for generating the clock SCL signal) or a slave device Slave, which can be used as a transmitter or a receiver. The I2C bus is converted into 9 bits at a time. The first 8 bits transmit data in the order from MSB to LSB. The 9th bit is the ACK bit. When the SCL signal is high, the change of the SDA state is used to start and stop the conversion. In addition, the transmission of each data bit requires the support of an SCL cycle. During the data transmission process, when SCL is high, the data on the SDA line must be maintained. Only when SCL is low can the state (data) of the SDA line be changed. The basic I2C communication process is: START (RESTART) à 7-bit peripheral chip address + R/~W control bit à 8-bit peripheral chip internal register address à multiple data bytes transmitted à STOP. The I2C bus data transmission timing is shown in Figure 1.
Figure 1 I2C bus data transmission timing
3. ZLG7290 expansion chip
ZLG7290 is a keyboard and LED driver based on I2C interface developed by Guangzhou Zhou Ligong Single Chip Microcomputer Development Co., Ltd. It can drive 8-bit common cathode digital tube or 64 independent LEDs and 64 buttons. ZLG7290 provides two control modes: register image control and command interpretation control. Register image control refers to directly accessing the underlying registers in byte operation mode to achieve basic control functions; command interpretation control refers to indirectly accessing the underlying registers by interpreting the instructions in the command buffer CmdBuf0/CmdBuf1 to achieve extended control functions such as register bit operations, circular shift of display buffer, and operand decoding. The slave address of ZLG7290 is 70H (01110000B), and the address of the internal register is 00~17H. The internal function block diagram of ZLG7290 is shown in Figure 2. In this application, the register image control mode is adopted to control the LED.
Figure 2 ZLG7290 internal function block diagram
4. Implementation of PIC18F458 based on I2C communication
PIC18F458 is a high-end 8-bit FLASH microcontroller with an integrated CAN controller developed by MICROCHIP. It has 32K bytes of FLASH program RAM space, 1536 bytes of RAM + 256 bytes of EEPROM for data storage, and a total of 33 I/O ports[6][7]. The master synchronous serial port (MSSP) module of PIC18F458 provides SPI and I2C communication functions. Pins RC4 and RC3 are used as the data SDA line and clock SCL line in I2C mode respectively. There are 6 registers related to I2C communication control inside, namely: MSSP control register 1 (SSPCON1), MSSP control register 2 (SSPCON2), MSSP status register (SSPSTAT), serial receive/transmit buffer (SSPBUF), MSSP shift register (SSPSR) and MSSP address register (SSPADD). Among them, SSPCON1/SSPCON2 are used to set the working mode, and SSPADD is used to set the device address (when PIC18F458 is used as SLAVE) or communication baud rate (when PIC18F458 is used as MASTER). In MASTER mode, the value of SSPADD should satisfy the following formula:
(Dark/4)/FI2C=SSPADD+1
in:
Fosc/4: PIC18F458 internal clock frequency, fixed to 1/4 of the crystal frequency;
FI2C: The maximum rate of I2C communication, unit: kbit/s, generally 100kbit/s
The SSPADD value must be rounded to the smallest integer greater than or equal to the calculated value.
Figure 3 shows the hardware wiring when PIC18F458 controls ZLG7290 as the vehicle body status display driver. Pins 19 and 20 of ZLG7290 are used to realize communication control with PIC18F458. The display control is realized in the program mainly by calling functions WriteByte(SCANNUM, 0x01) and WriteByte(DPRAMi, Dig2word), where SCANNUM is the number of scans and DPRAMi (i=0~7) is the segment code display buffer corresponding to the 8 digital tubes. As shown in Figure 3, if all 8 LEDs in the column where LED D1 is located are to be lit, the corresponding display buffer value should be 0XFF.
Figure 3 Hardware wiring when PIC18F458 controls ZLG7290 as a vehicle body status display driver
5. Conclusion
Using the I2C bus interface to expand the port of the microcontroller greatly simplifies the design of the peripheral hardware circuit of the embedded system and improves the reliability of the system; at the same time, it also simplifies the design of the system control software and achieves good application results in the vehicle body condition display control system based on PIC18F458. According to the method introduced in this article, ZLG7290 or similar chips can be easily applied to other types of MCU applications of MICROCHIP.
References
1.THE I2C-BUS SPECIFICATION,VERSION 2.1,www.semiconductors.philips.com /i2c/support
2. Wu Qiang, Huang Shihong. Research on the application of I2C bus in intelligent vibration tester. Microcomputer Information, 2002(10)
3. Li Cai et al. Application of clock chip PCF8563 in ocean optical buoy. Electronic Products World, 2003(7)
4. Jin Ming, Tao Weiqing. MSP430 series microcontroller and I2C bus EEPROM interface. Instrument and Meter User, 2003 (6)
5. Li Qiusheng, Wang Yuezhong. Application of VB6-based PC and multiple single-chip microcomputer communication in lithium battery detection and formation equipment. Microcomputer Information, 2003 (10)
6.PIC18FXX8 DATA SHEET, www.microchip.com
7.[美]约翰 B.皮特曼 著,郑红等译. PIC18F452微控制器嵌入式设计.科学出版社,2005,1
Previous article:Design of Embedded Remote Controller Based on Telephone Network
Next article:Design Research of PIC18F452
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers (Second Edition) (Wanlong)
- singlechip-implementation-of-levelcrossing-adc-for-ecg-sampling-2332-0796-1000219
- Electromagnetic compatibility interface circuit design scheme
- Low-Noise, High-Precision Linear Power Supply with Thermal Foldback Protection
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to record and call script files in Allegro software?
- TI Cup 2019 National Undergraduate Electronic Design Competition National Review Results Announcement
- Current reversible chopper circuit
- [TI Live Broadcast] The new generation of C2000 and MSP430 series is released, take a look! Register to watch and win gifts
- Do you remember the ZTE power supply I bought at the ghost market? I DIYed it in my spare time.
- Notes on commonly used modules inside MSP430 microcontroller
- Share: CCS dual-core chip DSP end development
- I would like to ask how the parameters of the bandpass filter are derived.
- How to use Wireshark to capture Zigbee packets
- esp32 flash micropython firmware plug in computer no such file directory