Reprint: Principles, Differences and Applications of Three Serial Buses of SPI, I2C and UART

1. UART is two lines, one for sending and one for receiving, which can communicate in full duplex, and the number of lines is relatively small. The data is transmitted asynchronously, the timing requirements for both parties are relatively strict, and the communication speed is not very fast. It is most used in multi-machine communication.

2. Compared with the above UART, the SPI interface has an additional synchronous clock line. The disadvantage of the above UART is its advantage. The timing requirements for both 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 the product, such as large-capacity memory.

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

SPI: High-speed synchronous serial port. 3 to 4-wire interface, independent transceiver and synchronous
UART: Universal Asynchronous Serial Port. Complete two - way communication according to the standard

baud rate , slow speed Transceiver UARTs are chips used to control computers and serial devices. One thing to note is that it provides an RS-232C data terminal device interface so that the computer can communicate with a modem or other serial device that uses an RS-232C interface . As part of the interface, the UART also provides the following functions: Convert the parallel data transmitted from the computer to the output serial data stream. Converts serial data from outside the computer into bytes for use by devices that use parallel data inside the computer. Add parity bits to the output serial data stream , and perform parity check on the data stream received from outside. Add a start-stop marker to the output data stream,









And remove the start-stop marker from the received data stream. Handles interrupts signaled by the keyboard or mouse (keyboards and mice are also
serial devices). It can handle the synchronization management of the computer and external serial devices. Some high-end UARTs
also provide buffers for input and output data. Now the newer UART is 16550, which can store 16 bytes of data in its buffer before the computer needs to
process the data, while the usual UART is 8250. Now if you buy a built-in
modem, the modem usually has a 16550 UART inside it.
I2C: Can be used to replace the standard parallel bus, which can connect various integrated circuits and functional modules. I2C is a multi-master bus, so any one device can act like a master and control the bus. Each device on the bus has a unique address, and depending on the device's own capabilities, they can work as either a transmitter or a receiver . Multiple microcontrollers can coexist on the same I2C bus.

I-Side C-Bus:

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

Because the interface is directly on top of the components, the I2C bus takes up very little space, reducing board space and chip pin count, reducing interconnect costs. The bus can be up to 25 feet in length and can support 40 components at a maximum transfer rate of 10Kbps. Another advantage of the I2C bus is that it supports multimastering, where 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 point in time.

UART:

单端,远距离传输。大多数计算机包含两个基于RS232的串口。串口同时也是仪器仪表设备通用的通信协议;很多GPIB兼容的设备也带有RS-232口。同时,串口通信协议也可以用于获取远程采集设备的数据。串口通信的概念非常简单,串口按位(bit)发送和接收字节。尽管比按字节(byte)的并行通信慢,但是串口可以在使用一根线发送数据的同时用另一根线接收数据。它很简单并且能够实现远距离通信。比如IEEE488定义并行通行状态时,规定设备线总常不得超过20米,并且任意两个设备间的长度不得超过2米;而对于串口而言,长度可达1200米。

具体的适用范围就可多了,军用,医疗...到处到能用。

第一个区别当然是名字:
     SPI(Serial Peripheral Interface:串行外设接口);
     I2C(INTER IC BUS:意为IC之间总线)
     UART(Universal Asynchronous Receiver Transmitter:通用异步收发器)

第二,区别在电气信号线上:
     SPI总线由三条信号线组成:串行时钟(SCLK)、串行数据输出(SDO)、串行数据输入(SDI)。SPI总线可以实现多个SPI设备互相连接。提供SPI串行时钟的SPI设备为SPI主机或主设备(Master),其他设备为SPI从机或从设备(Slave)。主从设备间可以实现全双工通信,当有多个从设备时,还可以增加一条从设备选择线。
     如果用通用IO口模拟SPI总线,必须要有一个输出口(SDO),一个输入口(SDI),另一个口则视实现的设备类型而定,如果要实现主从设备,则需输入输出口,若只实现主设备,则需输出口即可,若只实现从设备,则只需输入口即可。

     I2C总线是双向、两线(SCL、SDA)、串行、多主控(multi-master)接口标准,具有总线仲裁机制,非常适合在器件之间进行近距离、非经常性的数据通信。在它的协议体系中,传输数据时都会带上目的设备的设备地址,因此可以实现设备组网。
     如果用通用IO口模拟I2C总线,并实现双向传输,则需一个输入输出口(SDA),另外还需一个输出口(SCL)。(注:I2C资料了解得比较少,这里的描述可能很不完备)

     UART总线是异步串口,因此一般比前两种同步串口的结构要复杂很多,一般由波特率产生器(产生的波特率等于传输波特率的16倍)、UART接收器、UART发送器组成,硬件上由两根线,一根用于发送,一根用于接收。
     显然,如果用通用IO口模拟UART总线,则需一个输入口,一个输出口。

第三,从第二点明显可以看出,SPI和UART可以实现全双工,但I2C不行;

第四,看看牛人们的意见吧!
     wudanyu:I2C线更少,我觉得比UART、SPI更为强大,但是技术上也更加麻烦些,因为I2C需要有双向IO的支持,而且使用上拉电阻,我觉得抗干扰能力较弱,一般用于同一板卡上芯片之间的通信,较少用于远距离通信。SPI实现要简单一些,UART需要固定的波特率,就是说两位数据的间隔要相等,而SPI则无所谓,因为它是有时钟的协议。
     quickmouse:I2C的速度比SPI慢一点,协议比SPI复杂一点,但是连线也比标准的SPI要少。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325775242&siteId=291194637