当前位置:网站首页>[STM32] basic knowledge of serial communication
[STM32] basic knowledge of serial communication
2022-07-24 00:50:00 【Coder_ Ja】
Basic knowledge of communication
Serial and parallel
According to the way of data transmission , Communication can be divided into serial communication and parallel communicationserial communication : Only one data bit can be transmitted at a time , Like a one lane highway
Parallel communication : Data that can transmit multiple data bits at a time , Like a multi lane highway
Feature comparison

Transmission direction
according to serial communication The direction of data transmission , The serial communication mode can be divided into : Simplex 、 Half duplex 、 full duplexSimplex : Data transmission can only go in one direction , Cannot reverse transmit
Half duplex : Data transmission can be in two directions , But not at the same time , That is, there is a sequence between sending and receiving
full duplex : Data transmission can be in two directions , And can be sent at the same time
Half duplex both sides share a line to realize two-way communication , Full duplex uses two lines , Send data one by one 、 One receipt data .



Synchronous and asynchronous
Synchronous communication : Both receiving and sending equipment will Use a signal line to represent the clock signal , Driven by the clock signal, the two sides coordinate 、 Synchronous data , In communication, both parties usually It is uniformly stipulated to sample the data line on the rising or falling edge of the clock signalasynchronous communication : Do not use clock signals Data synchronization , Directly insert some signal bits for synchronization into the data signal , Or package the subject data , Transmit data in the format of data frames . Need both sides Agreed data transmission rate ( Baud rate ), To better synchronize .
Data synchronization means that both parties need to know when to start sending data 、 When data transmission ends , Otherwise, invalid data will be received .

Serial port communication
USART Universal Synchronous Asynchronous Receiver Transmitter Universal synchronous asynchronous transceiver , It can flexibly exchange full duplex data with external devices .UART And USART The difference is that it only has asynchronous communication , There is no synchronous communication .
USART yes STM32 Based on serial port protocol to achieve external communication with a peripheral , Because the serial communication protocol is simple 、 convenient , So most products support serial communication , It can be realized through serial port communication PC And STM32 Interaction , It plays a very important role in debugging and development .
Serial port communication is a common way of serial communication
Serial communication can be divided into physical layer and protocol layer . The physical layer specifies that the communication protocol has mechanical properties 、 Characteristics of electronic functions , Ensure the dissemination of raw data in physical media ; The protocol layer specifies the communication logic , Unified data packaging 、 Unpacking standard .
The physical layer
The main standard of serial communication physical layer is RS-232, It specifies the purpose of the signal 、 Communication interface and signal level standard , The communication structure is as follows
DB9 Interface
Levels of different standards
For controller TTL level , If you want to use other standards for communication between controllers , Need to be connected to level conversion chip , take TTL The level is converted to other standard levels .TTL The level transmission distance is short , Generally, the communication distance is greater than 40cm When transmitting data, it will be interfered .
Protocol layer
The content of the data package is specified in the protocol layer , From start bit 、 Subject data 、 Check bit and stop bit , The data packet format of both communication parties should be agreed to be consistent in order to send and receive data normally
- Baud rate
Baud rate is the number of symbols transmitted per second . Because there is no clock signal in asynchronous communication , So both sides should agree on the baud rate . Common baud rates are 4800、9600、115200 etc. - Start and stop signals
The beginning and end of the packet are the start bit and stop bit respectively , The starting signal consists of a logic 0 The data bits of the , Stop bit can be 0.5、1、1.5、2 A logic 1 The data bits of the , Both parties need to agree - Valid data
Valid data specifies the length of the subject data , It's usually 8 or 9 position - data verification
After the valid data , There is an optional data check bit . because Data communication is vulnerable to external interference, resulting in deviation of transmitted data , This problem can be solved by adding check bits in the transmission process . There are odd check methods (odd)、 Even check (even)、0 check (space)、1 check (mark) And none (noparity).
Function pin
TX: Send data output pin .RX: Receive data input pin .
SW_RX: Data receiving pin , Only for single line and smart card modes , Belongs to the internal pin , No specific external pins .
nRTS: Request to send (Request To Send),n Indicates that the low level is active . If enabled RTS flow control , When USART When the receiver is ready to receive new data, it will nRTS Turn to low level ; When the receive register is full , nRTS Will be set to high level . This pin is only suitable for hardware flow control .
nCTS: Clear to send (Clear To Send),n Indicates that the low level is active . If enabled CTS flow control , The transmitter will detect before sending the next frame of data nCTS Pin , If it's low level , Indicates that data can be sent , If it is high, the transmission is stopped after the current data frame is transmitted . This pin is only suitable for hardware flow control .
SCLK: Transmitter clock output pin . This pin is only available in synchronous mode .

USART There are five pins ;UART Only asynchronous communication , Only two pins .
Serial port pin connection : TX Pick up RX,RX Pick up TX
边栏推荐
- The postman test interface has 404 or 500 errors when the URL is configured correctly
- 这是一道大水题
- 【电赛训练】非接触物体尺寸形态测量 2020年电赛G题
- Tutorial on the principle and application of database system (044) -- MySQL query (VI): using the limit option to realize paging query
- The high-quality digital collection of guochuang's "children's song line" is on sale, and you are invited to create a young martial arts Jianghu dream
- AWS Article 3 how to publish message to IOT mqtt in go language
- MySQL's heart index
- Creo 9.0 mouse button operation for model observation
- Redis persistence mechanism RDB, AOF
- [QNX Hypervisor 2.2用户手册]9.1 配置变量
猜你喜欢

这是一道大水题

Image processing: Generation 3 × Window of 3

Focus on microservices

網絡系統實驗:ping不通的問題解决

EFCore高级Saas系统下单DbContext如何支持不同数据库的迁移

网络系统实验:ping不通的问题解决

MySQL's heart index

Case error of MySQL branch statement

Testers who have been employed for 3 months are facing employment confirmation. Leaders: 1 year of work experience is packaged into 5 years, and the probation period is eliminated

NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library ‘*****‘
随机推荐
A good habit to develop when writing SQL
MariaDB database upgrade version
Pbootcms database conversion tutorial (SQLite to MySQL detailed tutorial)
北峰通信亮相中国(厦门)应急展|智能化通信手段强势吸睛!
Redis | very important Middleware
网络系统实验:ping不通的问题解决
Testers who have been employed for 3 months are facing employment confirmation. Leaders: 1 year of work experience is packaged into 5 years, and the probation period is eliminated
这是一道大水题
Tutorial on the principle and application of database system (044) -- MySQL query (VI): using the limit option to realize paging query
Dataframe.groupby learning materials
Multi data source configuration of mongodb
Notes and Thoughts on the red dust of the sky (VI) due to lack
Accelerating matrix vector multiplication of special matrices with FFT
Summary of the fourth week of summer vacation
C language writing specification
【数据挖掘工程师-笔试】2022年海尔 公司
多源文件方式去访问全局变量的方式(extern用法)
T-seda code
【LeetCode第 83 场双周赛】
Introduction to several scenarios involving programming operation of Excel in SAP implementation project