At present, the diversified functions of consumer electronic products (such as color TVs, stereos, etc.) make the control circuit more complicated. The I2CBUS (Inter ICBUS) bus introduced by Philips is the most concise, effective and widely used bus format among many buses. The I2C bus is usually implemented in hardware, which requires the selected device to have an I2C bus interface, but the widely used MCS-51 series microcontrollers do not have a dedicated hardware part for the I2C bus. This article combines the author's use of the microcontroller 8031 to control the stereo audio processing chip TDA7313 with an I2C bus interface, and introduces the design method and program of the I2C bus and the microcontroller application system based on the I2C serial bus.
1 Introduction to I2C Bus
1.1 Composition of I2C bus
The I2C serial bus uses two signal lines, the bidirectional data line (SDA) and the serial clock line (SCL), to transmit information between devices connected to the bus. It is a multi-master bus, and Figure 1 shows its block diagram. Each device on the bus can be set with a unique address, and then send or receive information according to the set function. In addition to being a transmitter and receiver, the devices on the bus can also be set as masters and slaves when performing data transmission. The master controller usually starts data transmission on the bus and generates the clock signal required for data transmission. The other devices addressed by it are all slaves, which means that multiple devices with control buses can be connected to the bus.
Figure 1 I2C bus composition
The data transmission rate on the I2C bus is 100 kbit/s, and can reach 400 kbit/s in fast mode. The number of devices connected to the bus is limited only by the bus capacitance of 400 pF. At the same time, in order to avoid confusion of bus signals, the output terminals of each device connected to the bus must be open collector or open drain to produce the "line and" function. The SDA and SCL lines on the I2C bus are both bidirectional transmission lines. They can be connected to the positive power supply terminal through a resistor. When the bus is in an idle state, both lines are high level.
1.2 I2C bus data transmission format
During the I2C bus transmission process, data transmission can only start when the bus is idle (both the SCL line and the SDA line are high), and any device on the bus can control the bus at this time. Figure 2 shows two specific start and stop conditions, where the start condition (S) is when the SCL line is high and the SDA line changes from high to low; and the end condition (P) is when the SCL line is high and the SDA line changes from low to high. During the data transmission process, when the SCL line is high, the SDA line must be stable high or low to make the data valid. The state of the SDA line can only change when the clock signal on the SCL line is low, and one clock pulse is required for each bit of data. All data is sent in bytes, and the number of bytes sent each time is unlimited. After each byte is sent, the master controller releases the SDA line (high level) and the slave pulls down the SDA line, so that the SDA line is stable low as a valid response bit to indicate successful transmission. At this time, the master controller must generate an additional clock pulse corresponding to this bit.
Figure 2 I2C serial bus data operation timing
Figure 3 shows the data transmission format of the I2C bus. The first part is the data transmission start signal, which is where data transmission begins; the second part is the slave address, which is used to select which slave to transmit data to; the third part is the read/write control bit, which is used to indicate the working mode of the slave, 0 means write, 1 means read; the fourth part is the confirmation signal sent back by the slave selected by the master to the master; the fifth part is the transmitted data, and each byte of data transmitted requires an acknowledgement bit; the sixth part is the end signal of data transmission.
Figure 3 Data transmission format
Each controlled device with an I2C bus interface has a unique fixed address. When the master controller sends data, the controlled device connected to the I2C bus will compare the 8-bit address information sent by the master controller after the start signal with its own address. If the two are the same, the controlled device is considered to be selected, and then receives or sends data according to the working mode specified by the read/write bit.
2 Implementation of I2C bus in microcontroller
The IC control chip used in this audio processing system is TDA7313, which is a stereo audio digital processing device with volume, left and right balance of high and low pitch, and front and back mixing adjustment. Its input channel can be selected, and it has corresponding external loudness adjustment function and I2C serial bus interface, so it can be widely used in car audio and high-fidelity systems. The connection between TDA7313 and microcontroller 8031 and the basic pin definition are shown in Figure 4.
Figure 4 Interface circuit between MCU and TDA7313
Since the 8031 microcontroller does not have an I2C bus hardware interface, the serial clock signal can only be generated by writing software. When the system transmits data, the microcontroller first gives a start signal; then sends the 7-bit address and read/write control bit of the device TDA7313 and waits for the response signal; after receiving the response signal, the system performs corresponding operations according to the access requirements. In the actual operation process, the CPU generally inputs a series of specific digital commands to TDA7313 to realize the audio processing of the entire system, so the operation of TDA7313 is mainly write operation.
Previous article:Parallel expansion and interface design of I2C interface of 8051 microcontroller
Next article:Using the I/O port of a single-chip microcomputer to drive 74LS164
Recommended ReadingLatest update time:2024-11-23 20:54
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- 7. Common Collector Amplifier Circuit (Emitter Follower)
- [Repost] A brief analysis of the "maximum supply current" of operational amplifiers
- Effects of Interference on CDMA Mobile Phone Receiver Testing
- Verilog state machine programming skills
- Review summary: Qinheng RISC-V core BLE 5.3 wireless MCU CH582
- MSP-EXP430F5529LP Development Board 002-GPIO Library Function
- Lederui specializes in Type-C interface and HOST solution for laptops/tablets
- Application of PLC and TP
- Domestic FPGA Gaoyun GW1N-4 series development board evaluation - unboxing + hardware part 2
- Please help me take a look at this strange MICRO BIT board