UART, I2C, SPI three protocols Comparison

Embedded need to learn to lay the foundation

Let's learn three common bus protocol in principle and the principle of lower computer

 

Protocol: a set of peers to exchange data or communications between entities must comply with the rules or standards

1、UART(Universal Asynchronous Receiver/Transmitter):

Universal Asynchronous Receiver Transmitter, also known as serial, basically for debugging

Three wires: RX, TX, GND

If the PC is A, B is a single chip, both also connected to a level converter chip, for TTL / CMOS (SCM level) is converted to the RS232 (PC organic level). Since TTL / CMOS level range 0~1.8 / 2.5 / 3.3 / 5V (different range of microcontroller), 1 represents a high voltage, 0 represents a low voltage logic levels and RS232 -12V~12V, -5~-12 represents high, + 5~ + 12V represents the low level (you heard it right!) Why do you set up which would be traced back to modem era was born, and are interested to find information themselves

 

When the boards want to send data, the RXD0 from 1 to 0, retention time T

PC feel RXD0 know changes from 0 to 1.2440 forthcoming data

 

 There are start and stop bits, it means that this is asynchronous communication

 

2、I^2C协议(Inter Integrated Circuit)

Two lines SCL (clock), the SDA (data) only one data line, so that a half-duplex synchronous communication,

There are three types of signals during data transfer: start signal, the end signal and the corresponding signals.

(1) start signal (S): SCL is high, the SDA transitions from high to low to start the data transfer

(2) end signal (P): SCL is low, the SDA LOW to HIGH transition, the end of the data transfer

(3) a response signal (ACK): a receiver after receiving the 8-bit data, at the ninth clock cycle, pull down the SDA level

 

 

A plurality of devices can be connected, to turn a device, sent to the host signal S, 8-bit data is then sent. The first seven bits slave address (it can take 2 ^ 7 = 128 units), the eighth bit indicates the direction of transmission (0 indicates a write operation, 1 indicates a read operation), there is the device, send the ACK response signal to start read / learn operation

 

 

 3, SPI (Serial Peripheral Interface, synchronous peripheral interface), full-duplex synchronous serial bus,

该总线大量用于与EEPROM,ADC,FRAM和显示驱动器之类的慢速外设器件通信。

3条线

SCK:时钟信号

SDI:输入信号

SDO:输出信号

CS:片选信号,决定了唯一的与主设备通信的从设备,片选信号低电平有效,不同于I^2C用的地址选择从机

 

 

 

对比:

UART是全双工,异步传输,对时序要求比较严格,速度较慢

SPI相比UART多了一条同步时钟线,通信速度快

I2C一根数据线,速度不高,结构简单

 

Guess you like

Origin www.cnblogs.com/cyyz-le/p/10929920.html