当前位置:网站首页>STM32 - Communication
STM32 - Communication
2022-07-28 22:39:00 【Green hedgerow bamboo maple】
Communication classification
(1) Serial communication and parallel communication
Serial communication : It refers to a small number of data signal lines between devices ( commonly 8 Below root ), Ground wire and control signal wire , A communication method that transmits data bit by bit in the form of data bits , Like a bicycle lane
Parallel communication : Generally speaking, it refers to the use of 8,16,32, as well as 64 One or more data lines for transmission , It's like multiple lanes
| characteristic | Serial communication | Parallel communication |
| Communication distance | Far away | Closer |
| Anti interference capability | Stronger | Weak |
| Transmission rate | slower | Faster |
| cost | The lower | Higher |
(2) According to the direction of data communication , It can be divided into full duplex , Half duplex and Simplex Communications , It is mainly distinguished by the direction of the channel
full duplex : At the same time , Two devices can send and receive data at the same time
Half duplex : Data can be sent and received between two devices , But not at the same time
Simplex : Only one direction of communication can be carried out at any time , That is, a fixed transmission device , The other is fixed as a receiving device
(3) According to the data synchronization mode of communication , It is divided into synchronous communication and asynchronous communication
Generally, it can be based on the communication process , Whether the clock signal is used for simple differentiation

High efficiency of synchronous communication , But the requirements for clock synchronization of both sides are high
Communication rate
A very important parameter to measure the communication performance is the communication rate , Usually expressed in bit rate , And the binary number transmitted per minute , In bits per second (bit/s), Bityes 2 States ,0 perhaps 1
Baud rate : Indicates how many symbols are transmitted in seconds , The unit is baud/s, Symbol is the concept of communication signal modulation , A code can be represented by multiple binaries , For example, define a communication method 1 A symbol a use 2 individual bit Express , If 1 One symbol per second , So the baud rate is 1, The bit rate is 2, When the bit rate is equivalent to the baud rate , Default 1 For symbols 1 individual bit Express , namely 1 potter =1 Code element
USART—— Communication synchronous asynchronous transceiver
UART The period is mainly used for Generate protocol signals of relevant interfaces , Such as RSC232/RS485 Serial interface standard specification and bus standard specification , Use these interfaces to transmit data , It is necessary to send data according to the protocol signal specified by the interface , therefore UART Devices are widely used in serial communication , Play the role of folding conveyor
STM32 and PC adopt RS-232 Standard communication

RS-232 It is the standard for serial data communication formulated by the American Electronic Industry Alliance , It is widely used in computer serial interface peripheral connection ,RS-232 The standard specifies connecting cables and machinery , Electrical characteristics , Signal function and transmission process
Generally, the comment mark used on the development board can be different from the comment standard used in communication , such as TTL Standards and RS-232 standard
| Communication standards | Level standard ( The sender ) |
| 5V TTL | Logic 1:2.4V~5V Logic 0:0~0.5V |
| RS-232 | Logic 1:-15V~-3V Logic 0:+3V-+15V |
Because controllers generally use TTL Level standard , So we often use MA3232 chip ( Level conversion chip ) Yes TTL as well as RS-232 Level signals are converted to each other
RS-232 Standard data transfer protocol layer
The data packet of serial communication is sent by the sending device through its own TXD Interface to the receiving device RXD Interface , In the serial communication protocol layer , Specifies the content of the packet , Including the start bit , Subject data , The check bit is composed of stop bits , The data packets of both communication parties should be agreed to be consistent in order to send and receive data normally

Concept of agreement
Baud rate : There is no clock signal in asynchronous communication , Therefore, the baud rate needs to be agreed between the two communication devices , That is, the length of each symbol , To decode the signal , The common baud rate is 4800,9600,115200 etc.
Start and stop signals of communication
A packet of serial communication starts with the starting signal , Until the stop signal is over , The starting signal of the data packet consists of a logic 0 The data bits of the , The stop signal of the data packet can be 0.1,1,1.5, or 2 A logic 1 The data bits of the , As long as both parties agree
Valid data
The main data content to be transmitted is immediately followed by the start bit of the packet , Also known as valid data , The length of valid data is often agreed as 5,6,7,8 Bit length
data verification
After the valid data , There is an optional data bit check , Because data communication is relatively vulnerable to external interference, resulting in transmission data deviation , This problem can be solved by adding check bits in the transmission process , The verification method includes parity ,0 The checksum 1 Check and no check
Use CubeMX Configure serial port

(1) First set the clock

(2) Set up the system SYS

(3) Set the serial port

The default pin is PA9 and PA10, Can be modified according to your own needs , Here, according to USB The serial port diagram is changed to PB6 and PB7

Set interrupt enable

It has been set up here , You can generate layer code
边栏推荐
- 770. 单词替换
- Using nodejs to operate MySQL
- 770. Word replacement
- Closure, prototype and original link
- NPM switch Taobao source (NPM source)
- internet的基本服务中文件传输命令是哪个
- Imx6q GPIO multiplexing
- 775. 倒排单词
- Install PCL and VTK under the background of ROS installation, and solve VTK and PCL_ ROS conflict problem
- 微信小程序剪切图片的功能
猜你喜欢

静态成员static详解

LVS+KeepAlived高可用部署实战应用

Win11 how to open software notification
![[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN](/img/7f/c49fd8c2cbe21585a080852833dcb4.png)
[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN

CMD common commands

Quadruped robot | gem (elevation map) + fast_ Deployment records of Leo (odometry) environment

Research cup element recognition multi label classification task based on ernie-3.0 cail2019 method

flask之蓝图 补充openpyxl

PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)

How to install WiFi correctly
随机推荐
Win11怎么打开软件通知
二进制的原码、反码、补码
微信小程序里button点击的时候会边框有黑线
Soft exam network engineer
Jianzhi offer II 062. implement prefix tree (medium design dictionary tree prefix tree string)
ES6, deep copy, shallow copy
Paddlenlp is based on ernir3.0 text classification. Take the traditional Chinese medicine search and retrieval semantic map classification (kuake-qic) as an example [multi classification (single label
Sword finger offer II 067. maximum XOR (medium prefix tree bit operation array)
Command line agent: proxychains configuration
Imx6q GPIO multiplexing
MySQL built-in functions
Static route and default route experiment
NPM switch Taobao source (NPM source)
There will be a black line on the border when the button in the wechat applet is clicked
Sword finger offer II 064. magic Dictionary (medium dictionary tree string design)
Qt+FFmpeg环境搭建
The blueprint of flask complements openpyxl
LeetCode刷题系列之-多数之和类型
mysql8.0无法给用户授权或提示You are not allowed to create a user with GRANT的问题
Research cup element recognition multi label classification task based on ernie-3.0 cail2019 method