The first difference, of course, is the name:

SPI (serial peripheral interface);

I2C (inter IC bus: it means the bus between ICs)

UART (Universal Asynchronous Receiver Transmitter)

What are SPI, I2C, UART? What are their characteristics? What's the difference?

Second, the difference is on the electrical signal line:

SPI bus consists of three signal lines: serial clock (SCLK), serial data output (SDO) and serial data input (SDI). SPI bus can realize the interconnection of multiple SPI devices. The SPI device providing SPI serial clock is SPI master or master, and other devices are SPI slave or slave. Full duplex communication can be realized between master and slave devices. When there are multiple slave devices, a slave device selection line can be added.

If a general IO port is used to simulate SPI bus, there must be an output port (SDO), an input port (SDI), and the other port depends on the type of equipment to be realized. If a master-slave device is to be realized, an input and output port is required. If only a master device is to be realized, an output port is required. If only a slave device is to be realized, only an input port is required.

I2C bus is a bi-directional, two-wire (SCL, SDA), serial and multi master interface standard. It has a bus arbitration mechanism and is very suitable for short-distance and non recurrent data communication between devices. In its protocol system, the device address of the destination device will be brought when transmitting data, so the device networking can be realized.

If the general IO port is used to simulate I2C bus and realize bidirectional transmission, an input / output port (SDA) and an output port (SCL) are required. (Note: I2C information is not well understood, and the description here may be incomplete)

UART bus is an asynchronous serial port, so its structure is generally much more complex than that of the first two synchronous serial ports. It is generally composed of baud rate generator (the baud rate generated is equal to 16 times of the transmission baud rate), UART receiver and UART transmitter. The hardware consists of two lines, one for transmitting and one for receiving.

Obviously, if the universal IO port is used to simulate UART bus, one input port and one output port are required.

Third, it is obvious from the second point that SPI and UART can achieve full duplex, but I2C cannot;

Fourth, look at the opinions of cattle people!

Wudanyu: I2C has fewer wires. I think it is more powerful than UART and SPI, but it is also more troublesome in technology. Because I2C needs the support of two-way IO, and I2C uses pull-up resistor, I think its anti-interference ability is weak. It is generally used for communication between chips on the same board and less used for long-distance communication. SPI implementation should be simpler. UART needs a fixed baud rate, that is, the interval between two bits of data should be equal, while SPI doesn’t matter because it is a protocol with clock.

Quickmouse: the speed of I2C is a little slower than SPI, and the protocol is a little more complex than SPI, but the connection is also less than the standard SPI.

1. SPI (serial peripheral interface): high speed, full duplex, synchronous serial port.

Three or four signals are used for data exchange:

Simo: from in to out

SoMi: from out, main in

Uclk: clock, which is driven by the host and used by the slave to send and receive data

Ste: slave sending permission, which is used to control multiple slaves in multi master-slave system in four wire mode

Three wire SPI composition: serial clock (SCLK), serial data output (SDO), serial data input (SDI); When there are multiple slaves, you can also add a slave selection line. The four wire SPI mode uses an additional control line to allow the transmission and reception of slave data, which is controlled by the host.

SPI bus can realize the interconnection of multiple SPI devices.

The SPI device providing SPI serial clock is SPI master or master, and other devices are SPI slave or slave.

Full duplex communication can be realized between master and slave devices. SPI interface is to conduct synchronous serial data transmission between CPU and peripheral low-speed devices. Under the shift pulse of master devices, data is transmitted by bit, with the high position in the front and the position in the back, which is full duplex communication.

If a general IO port is used to simulate SPI bus, there must be an output port (SDO), an input port (SDI), and the other port depends on the type of equipment to be realized. If a master-slave device is to be realized, an input and output port is required. If only a master device is to be realized, an output port is required. If only a slave device is to be realized, only an input port is required.

UART needs a fixed baud rate, while SPI doesn’t matter because it is a protocol with a clock.

SPI interface is mainly used in EEPROM, flash, real-time clock, AD converter, digital signal processor and digital signal decoder.

2. I2C (inter IC bus) interface definition:

I2C bus is a two-way two-wire (SCL serial clock, SDA serial data line) synchronous serial bus with competition detection and arbitration mechanism, which can enable multiple hosts to send data at any time without damaging the data information on the bus. It is very suitable for short-range and non recurrent data communication between devices. In its protocol system, the device address of the destination device will be brought when transmitting data, so the device networking can be realized.

characteristic:

A. Each device connected to the bus can be addressed by the unique address of the software, and a simple master-slave relationship is established. The main device can be used as both a transmitter and a receiver.

B. The synchronous clock allows devices to communicate at different baud rates through the bus

C. The synchronous clock can be used as a handshake to stop and restart the serial port transmission

D. The number of integrated circuit devices connected to the same bus is only limited by the total bus capacitance of 400pF

If the general IO port is used to simulate I2C bus and realize bidirectional transmission, an input / output port (SDA) and an output port (SCL) are required.

Note: the serial data line SDA and serial clock line SCL constituting the I2C bus must be connected to the positive power supply through the pull-up resistor RP, and the output pole of the device connected to the bus must be in the form of “open drain” or “open set” in order to complete the function of “line and”.

I2C is generally used for on-chip communication with less anti-interference, and it is generally used for on-board communication with the same resistance.

The differences between various interfaces are as follows:

1. UART and USART are two separate areas, but I don’t know the difference. UART is two lines, one sending and one receiving. It can communicate in full duplex, and the number of lines is relatively small. The data is transmitted asynchronously, the timing requirements of both sides are relatively strict, and the communication speed is not very fast. It is most used in multi computer communication.

2. Compared with UART, SPI interface has one more synchronous clock line. The disadvantage of UART is its advantage. The timing requirements of communication parties are not strict. Different devices can be easily combined, and the communication speed is very fast. It is generally used for high-speed data communication between internal components of products, such as large capacity memory.

3. I2C interface is also a two-wire interface. It transmits data between two wires through complex logical relationship. The communication speed is not high, and the program writing is also complex. Generally, single chip microcomputer system is mainly used to connect with small memory such as 24C02.

Leave a Reply

Your email address will not be published. Required fields are marked *