tags: STM32 Single -chip machine Embedded hardware
SPI (Serial Peripheral Interface) is a synchronous serial transmission specification launched by Motorola, the United States, and a single -chip microcontrol serial communication interface that is more commonly used now. This interface is a high -speed, full -time, and synchronized communication bus.
SPI is divided into two modes, one SPI communication system is usually a main device, one or more of the device. The main device provides clocks, and the device that receives the clock is from SLAVE (SLAVE). When there are multiple devices, they are managed through their own film selection signals. SPI is a full -duplex and no definition speed limit. The speed is generally set by the maximum clock frequency that the host or the clock can support.
SPI interfaces generally use four signal line communication: MOSI, MISO, SCK, CS
The SPI CLK line is not defined, so it can be set freely. The clock polar (CPOL) and the clock phase (CPHA) can be combined into four different modes.
Clock polarity (CPOL) defines the clock free status level:
Clock phase (CPHA) definition data collection time points:

The main setting mode of the main machine should be consistent, and the SPI can be set to be sent with low bytes or high bytes.
The advantage of SPI communication
shortcoming
The I2C bus is a serial and half -dual -tool bus launched by Philips. It is mainly used for communication between close -range, low -speed chips; IIC bus has two two -way signal lines. The data cable SDA is used for receiving data. The clock line SCL is used to synchronize the clock of the two parties. The hardware structure of the IIC bus is simple, the cost is low, and it is also a relatively common serial peripheral interface.
The IIC bus is a multi -host bus. The device connected to the IIC bus is divided into hosts and slaves. The standard communication rate is generally 100kbps and 400kbps at high speeds
The I2C host has the right to initiate and end a communication, and the console can only be called by the host. When there are multiple hosts on the bus at the same time, the I2C also has the function of conflict detection and tailoring to prevent errors from being generated. Each connection is connected to The devices on the I2C bus have a unique address (7bit), and each device can be used as a host or as a console (only one host at the same time). Work, the device that I2C bus sends the data on the bus when communicating is the transmitter, and the device that receives the data is the receiver.
After sending the start signal, the host must first send a byte of data. The high 7 -bit of the data is the address of the slave, and the lowest bit indicates the transmission direction of the subsequent byte. After receiving data, after all the boards received the byte data on the bus, these 7 addresses compared with their own addresses. If the same, it is considered to be found by the console, and then the eighth place is determined to be The transmitter or a receiver.

Start signal and stop signal
Byte transmission and response
Synchronous signal
The SCL SDA cable of I2C is generally a leakage state and requires an external pull -up resistance.
Advantage
shortcoming
Universal Asynchronous Receiver Transmitter is the universal asynchronous receiver, which is a general serial and asynchronous communication bus. The bus has two data cables, which can be sent and received for all -dual -workers. Generally called serial communication
TX: Data send interface
RX: Data receiving interface
The two devices are connected to the RX between the two devices, and the RX and TX can work normally. Pay attention

The composition of a frame of data: starting position + data bit + verification position + stop bit
Starting position: 1 bit, logic '0', indicating the beginning of transmission of a character
Data bit: The data to be sent is generally 5-9 bits, and 8-bit commonly used
Verification digits: 0 ~ 1, no verification/strange verification/occasional verification
Strange verification: When there are strange logic in the data bit '1', this bit is 0, otherwise it is 1
Puppet verification: When there are occasional logic ‘1’ in the data bit, this bit is 0, otherwise it is 1
Stop bit: It means the end of the transmission of a character, which can be 1, 1.5, 2 high levels
Free position: When the current line is not transmitted, it is a high level
Sequence of data transmission:First transmit the data of the data first, and then transfer the high position of the data
Communication speed (Potter rate): In the application of single -chip microcomputers, the common communication speed is 9600, 19200, 57600, 115200 bit/s
Advantage
shortcoming
As the most commonly used serial communication interface in single -chip microcomputer. Since it can be widely used in major systems, there are applicable application scenarios. Choose different interfaces according to the needs of different projects.
1.uart communication ------>Asynchronous serial communication Asynchronous: random, no clock line Synchronization: Time Clock Single work: A-> B Half duplex: A-> B or B-> a Full duplex: A-...
:https://mp.weixin.qq.com/s?__biz=MzUxMjEyNDgyNw==&mid=2247498262&idx=1&sn=c7d106299976104394e4ce682682747f&chksm=f96b88e2ce1c01f4bddec93439ee8c0adbdb63f5a4afc105ea03ab0a58ba3d48445965...
I2C (Inter-Integrated Circuit) bus concept: I2C communicationOnly 2 bidirectional buses are needed- A data line SDA (serial data), a clock line SCL (serial clock). The SDA line is used to transmit dat...
SPI: SPI (Serial Peripheral Interface) serial peripheral interface, full-duplex, synchronous serial 1, SPI bus consists of three signal lines: a serial clock (SCLK), serial data output (SDO), a serial...
First, SPI SPI (Serial Peripheral Interface) is a synchronous serial data transmission standard proposed by Motorola. It is widely used in many devices. interface The SPI interface is often referred t...
First, the introduction 1. SPI SPI (Serial Peripheral Interface) is a synchronous serial data transmission standard proposed by Motorola, which is widely used in many devices. interface The SPI interf...
SPI, IIC, UART difference The first difference is of course the name: SPI (Serial Peripheral Interface: Serial Peripheral Interface); I2C(INTER IC BUS) UART (Universal Asynchr...
1 UART, I2C and SPI comparison UART I2C SPI English name Universal Asynchronous Receiver/Transmitter Inter-Integrated Circuit Serial Peripheral Interface Chinese name Universal asynchronous transceive...
Article Directory 0 Several concepts 1 UART 2 SPI 2.1 SPI signal line 2.2 SPI transmission data mode (timing) 3 I2C 3.1 Idle state 3.2 Start bit and stop bit 3.3 Validity of data 0 Several concepts Tr...
This article focuses on the difference and contact of the three communication interfaces of the UART / I2C / SPI, helping to understand these three interfaces, after understanding, whether it is using...