Design method and program of single chip microcomputer application system based on I2C serial bus

Publisher:Radiant777Latest update time:2018-03-24 Source: eefocusKeywords:I2C Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    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

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

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.


Keywords:I2C Reference address:Design method and program of single chip microcomputer application system based on I2C serial bus

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

Summary of the process of reading and writing EEPROM using I2C in STM32
Configure I/O ports, configure mode, enable GPIO and clock Write: Check if SDA is idle. Checks whether the event was successful. Send a start signal according to the protocol Checks whether the event was successful. Issues the 7-bit device address and write mode. Checks whether the event was successful. The first ad
[Microcontroller]
Parallel expansion and interface design of I2C interface of 8051 microcontroller
    1 Introduction     I2C bus interface devices are widely used in video processing, mobile communications and other fields. In addition, general I2C bus interface devices, such as RAM, ROM, A/D, D/A, LCD driver with I2C bus, are also increasingly used in computers and automatic control systems. With the increasing a
[Microcontroller]
Parallel expansion and interface design of I2C interface of 8051 microcontroller
Fudan Microelectronics Launches Low-Power Ultra-Wide Voltage I2C Serial EEPROM
May 12, 2022, Shanghai - Shanghai Fudan Microelectronics Group Co., Ltd. Recently launched the low-power and ultra-wide voltage FM24LNXXX series I2C serial EEPROM memory, which can meet the application needs of CCM, white goods, electric meter instruments, 5G communications, automotive and other related appl
[Embedded]
P87LPC764 uses I2C bus to expand LCD display
1 Introduction The I2C bus is an inter-chip serial transmission bus introduced by Philips. It uses only two lines, the serial data line (SDA) and the serial clock line (SCL), to achieve perfect full-duplex synchronous data transmission, and can easily form a multi-machine system and peripheral device expansion s
[Microcontroller]
P87LPC764 uses I2C bus to expand LCD display
STM32 I2C deadlock issue
background In fact, this article has written about the solution a long time ago. After continuous practice and in-depth research, I found that the problem of hardware I2C deadlock has long been solved in the errata in the official manual of ST. However, I did not pay attention to the official documents and kept seekin
[Microcontroller]
STM32 I2C deadlock issue
I2C touch screen based on ARM processor S3C2440 and Linux system
0 Introduction With the development of computer-related technologies, ARM embedded systems are increasingly widely used and are increasingly integrated into people’s lives. Touch screen devices are widely used in this embedded field because of their friendly human-computer interaction, convenient and flexible operati
[Microcontroller]
I2C touch screen based on ARM processor S3C2440 and Linux system
Eclipse development and debugging of ARM bare metal programs (VI) About bare metal debugging i2c records
        Regarding bare metal debugging i2c record, I encountered many problems. Now they have been solved. Record them.   1. Overall planning         Since I am learning the function of a certain hardware, I think I should be able to do it with the simplest code without involving other hardware. So my plan is
[Microcontroller]
Eclipse development and debugging of ARM bare metal programs (VI) About bare metal debugging i2c records
I2C Protocol---I2C Timing Diagram Analysis
1. Introduction to I2C Protocol   The I2C communication protocol (Inter-Integrated Circuit) was developed by Phiilps. It has few pins, simple hardware implementation, strong scalability, and does not require external transceiver devices such as USART and CAN communication protocols. It is now widely used for communica
[Microcontroller]
I2C Protocol---I2C Timing Diagram Analysis
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号