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-15 07:05
- Popular Resources
- Popular amplifiers
- ESP32-S3 source code
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- EEWORLD University Hall----Live Replay: Melexis High Reliability Programmable Hall Switch
- 2. Onboard RGB light control
- Auxiliary trainer for plank and push-up exercises
- MSP430 sets the main clock source, main clock source and auxiliary clock source
- What are the transmission distances of Zigbee and Bluetooth respectively? Which one has unlimited distance transmission?
- Happy Little New Year! How many days off do you have for the New Year?
- [Pingtou Ge RVB2601 creative application development] 1. Understand Pingtou Ge chips and development platform
- Advantages of using pressure sensors in constant pressure water supply systems!
- How to Make DSP Digital Oscillator Generate Phase-Shifted Sine Wave
- One-to-two high power relay