Principles, differences and Applications of SPI, I2C, and UART Serial Bus

Source: Internet
Author: User
Tags sdo

 

Principles, differences and Applications of SPI, I2C, and UART Serial Bus

1. UART is a two-line interface. One transmission and one receiving interface can communicate with each other in full duplex mode, and the number of lines is relatively small. Data is transmitted asynchronously, with strict timing requirements on both parties, and the communication speed is not fast. It is used most frequently for multi-host communication.

2. Compared with the UART above, the SPI interface has an additional synchronous clock line. The disadvantage of the UART above is its advantages, the timing requirements of both parties are not strict and can be easily combined between different devices, and the communication speed is very fast. It is generally used for high-speed data communication between components of the product, such as large-capacity storage.

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

SPI: high-speed synchronous serial port. 3 ~ 4-line interface, independent and synchronous sending and receiving
UART: Universal asynchronous serial port. Bidirectional communication based on the standard baud rate is slow

SPI: A three-line serial transmission mode. The communication protocol and usage can be found on the Internet.
Bidirectional data transmission with three lines
Serial peripheral interface
UART: Universal asynchronous transceiver
UART is a chip used to control computers and serial devices. One thing to note is that it provides the end of RS-232C data
Device interface, so that the computer can communicate with the modem or other serial devices using the RS-232C Interface
. As part of the interface, UART also provides the following functions:
Converts parallel data transmitted from within a computer to the output serial data stream. Serial from outside the computer
Data is converted to bytes for devices that use parallel data in the computer. Add to the output serial data stream
Parity bit, and perform parity checks on the data streams received from the outside. Add the start and stop mark to the output data stream,
And delete the start and stop mark from the received data stream. Process the interrupt signal sent by the keyboard or mouse (the keyboard and mouse pass are also
Serial device ). It can manage the synchronization between computers and external serial devices. There are some relatively high-end UART
It also provides a buffer for the input and output data. Now the new UART is 16550, which can be processed on the computer
Before the data is stored in the buffer zone, the typical UART is 8250. Now, if you purchase a built-in
A modem, which usually has a 16550 UART in it.
I2C: it can be used to replace standard parallel bus and connect various integrated circuits and functional modules. I2C is a multi-master bus, so any device can work as the master controller and control the bus. Each device on the bus has a unique address that can work as a transmitter or receiver based on the capabilities of the device. Multi-channel microcontroller can coexist on the same I2C bus.

I-Party C bus:

The main advantage of I2C bus is its simplicity and effectiveness.

Because the interface is directly on the component, the space occupied by the I2C bus is very small, which reduces the space of the circuit board and the number of chip pins, and reduces the interconnection cost. The bus can be up to 25 feet in length and support 40 components at a maximum transmission rate of 10 Kbps. Another advantage of the I2C bus is that it supports multimastering, in which any device capable of sending and receiving can become the master bus. A master can control signal transmission and clock frequency. Of course, there can only be one master at any time point.

UART:

Single-ended, remote transmission. Most computers contain two RS232-based serial ports. Serial Port is also a universal communication protocol for instrumentation equipment; many devices are also compatible with the RS-232 port. At the same time, the serial communication protocol can also be used to obtain data from remote collection devices. The concept of serial communication is very simple. The serial port sends and receives bytes by bit. Although it is slower than byte parallel communication, the serial port can use one line to send data while the other line to receive data. It is simple and can implement remote communication. For example, when IEEE488 defines the parallel traffic status, the total length of the device line must not exceed 20 meters, and the length of any two devices must not exceed 2 meters. For the serial port, the length can be up to 1200 meters.

The specific scope of application can be more, military, medical... can be used everywhere.

The first difference is of course the name:
SPI (serial peripheral interface: serial peripheral interface );
I2C (Inter IC Bus: indicates the inter-ic Bus)
UART (Universal Asynchronous Receiver Transmitter: Universal asynchronous transceiver)

Second, the difference lies in the electrical signal line:
The SPI bus consists of three signal lines: sclk, SDO, and SDI ). The SPI bus allows multiple SPI devices to connect to each other. The SPI device that provides the SPI serial clock is the SPI host or master, and other devices are the SPI slave or slave ). Full duplex communication can be achieved between the master and slave devices. When there are multiple slave devices, you can also add a select line from the device.
If you use a general IO port to simulate the SPI bus, you must have an output port (SDO), one input port (SDI), and the other port depends on the type of the implemented device, if you want to implement a Master/Slave Device, You need to input the output port. If you want to implement only the master device, you need to output the port. If you want to implement only the slave device, you only need to input the port.

I2C bus is a two-way, two-line (SCL, SDA), serial, multi-master interface standard, with bus arbitration mechanism, it is ideal for close-range and non-regular data communication between devices. In its protocol system, the device address of the target device is always included during data transmission. Therefore, devices can be networked.
If you use a general IO port to simulate I2C bus and implement bidirectional transmission, you need an input/output port (SDA) and an output port (SCL ). (Note: I2C data is rarely known, and the description here may be incomplete)

The UART bus is an asynchronous serial port. Therefore, the structure of the two synchronous serial ports is much more complicated than that of the first synchronous serial ports. Generally, it is generated by the baud rate generator (the baud rate is 16 times the Transmission baud rate) UART Receiver, UART transmitter, hardware consists of two wires, one for sending, one for receiving.
Obviously, if a universal IO port is used to simulate the UART bus, an input port and an output port are required.

Third, we can see from the second point that SPI and UART can achieve full duplex, but I2C is not;

Fourth, let's take a look at the opinions of the ox!
Wudanyu: less I2C lines. I think it is more powerful than UART and SPI, but it is more technically troublesome because I2C requires bidirectional IO support and the pull-up resistance is used, I think the anti-interference capability is weak. It is generally used for communication between chips on the same board, and rarely for long-distance communication. SPI implementation is simpler. UART requires a fixed baud rate, that is, the two-digit data interval must be equal, while SPI does not matter because it has a clock protocol.
Quickmouse: the speed of I2C is a little slower than that of SPI. The protocol is a little more complex than SPI, but the connections are also less than standard SPI.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.