The principle, difference and application of three serial bus of SPI, I²c and UART

Source: Internet
Author: User
Tags sdo advantage

SPI, I²C, serial port, I believe if you are engaged in embedded development, will be used to the three communication protocols, serial port words because and baud rate related, so the general CPU or MCU will only be equipped with two or three serial port, and the transmission of data, the SPI and i²c use will be more, A blog was found below. Turn around,

1, the UART is two lines, one sends a receive, can be full duplex communication, the number of lines is also relatively small. The data is transmitted asynchronously, the timing requirements of both sides are stricter, and the communication speed is not very fast. The most used on multi-machine communication.

2, SPI interface and above the UART, more than a synchronous clock line, the shortcomings of the UART is its advantages, the timing of the communication between the two sides of the requirements are not strictly different devices can be easily combined, and communication speed very fast. Generally used in the internal components of the high-speed data communication above, such as large-capacity memory.

3, the I²c interface is also a two-wire interface, it is two lines through a complex logical relationship between the transmission of data, communication speed is not high, the program is also more complex to write. The general SCM system is mainly used to connect with small easy memory such as 24C02.

SPI: High-speed synchronous serial port. All-in-line interface, independent transceiver, can be synchronized
UART: Universal asynchronous serial port. Two-way communication at standard baud rate with slow speed

SPI: A serial transmission mode, three-wire system, the network can find its communication protocol and usage of
3 Wires for data bidirectional transmission
Serial Peripheral Interface Serial Peripheral Interface
UART: Universal Asynchronous transceiver
The UART is a chip used to control the computer and serial devices. One thing to note is that it provides the RS-232C data end
Device interface so that the computer can communicate with a modem or other serial device that uses the RS-232C interface
。 As part of the interface, the UART also provides the following features:
Converts the parallel data transmitted from inside the computer to the output serial data stream. A serial that is external to the computer
The data is converted to bytes for use by devices inside the computer that use parallel data. In the output serial data stream, add the
Parity bit and parity with the data stream received from the outside. Add a start-stop flag to the output data stream,
And remove the start-stop flag from the receiving data stream. Handles interrupt signals issued by the keyboard or mouse (keyboard and mouse tickets are also
Serial device). Can handle the problem of synchronization management between the computer and the external serial device. Some of the more upscale UART
Also provides a buffer for input and output data, now compared to the new UART is 16550, it can be processed in the number of computers
Store 16 bytes of data in its buffer, and the usual UART is 8250. Now if you purchase a built-in
Modem, there is usually a 16550 UART inside this modem.
I²c: Can be used to replace the standard parallel bus, can be connected to a variety of integrated circuits and functional modules. I²c is a multi-master bus, so any device can operate like a master controller and control the bus. Each device on the bus has a unique address that can work as a transmitter or receiver, depending on the device's own capabilities. A multi-channel microcontroller can coexist on the same i²c bus.

I-party C bus:

The main advantage of the I²C bus is its simplicity and effectiveness.

Because the interface is directly above the component, the I²c bus occupies very little space, reduces the board space and the number of chip pins, and reduces the interconnection cost. The bus can be up to 25 feet in length and can support 40 components at the maximum transfer rate of 10Kbps. Another advantage of the I²C bus is that it supports multi-master (multimastering), where any device capable of sending and receiving can become the main bus. One master controls the transmission and clock frequency of the signal. Of course, there can only be one master at any point in time.

Uart:

Single-ended, long-distance transmission. Most computers contain two RS232-based serial ports. Serial port is also a common communication protocol for instrumentation equipment, and many GPIB-compatible devices also come with RS-232 ports. At the same time, serial communication protocol can be used to obtain data of remote acquisition device. The concept of serial communication is very simple, the serial port bitwise (BIT) Send and receive bytes. Although it is slower than parallel communication by Byte (byte), the serial port can receive data with another line while sending data using one line. It is simple and enables long-distance communication. For example, when IEEE488 defines the parallel state of passage, the equipment line is usually not more than 20 meters, and the length of any two devices shall not exceed 2 meters, but for the serial port, the length can reach 1200 meters.

The specific scope of application can be many, military, medical ... Everywhere to be able to use.

The first difference is of course the name:
SPI (Serial peripheral Interface: Serial Peripheral Interface);
I²c (INTER IC bus: means IC between the buses)
UART (Universal Asynchronous Receiver transmitter: Universal Asynchronous transceiver)

Second, the difference is on the electrical signal line:
The SPI bus consists of three signal lines: Serial clock (SCLK), serial data output (SDO), serial data input (SDI). The SPI bus enables multiple SPI devices to be connected to each other. The SPI device that provides the SPI serial clock is an SPI host or master device (master), and the other device is an SPI slave or slave device (Slave). The master-slave device can achieve full-duplex communication, and when there are multiple slave devices, you can also add a line from the device selection.
If you use the Universal IO Port analog SPI bus, must have a output (SDO), an input port (SDI), the other port depending on the type of equipment to be implemented, if you want to implement the master-slave equipment, you need to input output, if only the main equipment, you need to export, if only to achieve from the device, you only need to input

I²c bus is two-way, two-line (SCL, SDA), serial, multi-master (multi-master) interface standard, with bus arbitration mechanism, is very suitable for the device between the near-distance, non-recurrent data communication. In its protocol system, the transmission of data will bring the device address of the destination device, so the device network can be implemented.
If you use a universal IO port to simulate the I²C bus and achieve bidirectional transmission, one input output (SDA) is required, and an output (SCL) is required. (Note: The data of i²c is relatively small, the description may be very incomplete)

UART Bus is asynchronous serial port, it is generally more complex than the first two synchronous serial port structure, generally by the baud rate generator (produced by the baud rate is equal to the transmission baud rate of 16 times times), the UART receiver, the UART transmitter composition, the hardware by two lines, one for sending, one for receiving.
Obviously, if the UART bus is simulated with a universal IO port, one input port and one output outlet are required.

Third, from the 2nd obvious can be seen, SPI and UART can achieve full duplex, but not i²c;

Four, look at the opinions of the cattle people.
WUDANYU:I2C line Less, I feel more powerful than the UART, SPI, but technically more troublesome, because I need bi-directional IO support, and the use of pull-up resistor, I think the anti-interference ability is weak, generally used for the same card on the chip between the communication, less for long-distance communication. The SPI implementation is simple, the UART needs a fixed baud rate, that is, the interval of two bits of data is equal, and the SPI does not matter, because it is a clock protocol.
The QUICKMOUSE:I2C is slower than the SPI, the protocol is a bit more complicated than the SPI, but the connection is less than the standard SPI.

Related Article

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.