当前位置:网站首页>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
边栏推荐
- Why doesn't the icon on the elment plus icon input display
- JS convert numbers to letters
- How to install WiFi correctly
- Can the MySQL create statement be used to create a table structure and append new records
- 基于Ernie-3.0 CAIL2019法研杯要素识别多标签分类任务
- Solve the problem that TS node xxx.ts executes TS code and reports errors
- JS implementation generates a random key of specified length
- Using nodejs to operate MySQL
- Sword finger offer II 065. The shortest word code (medium dictionary tree string array)
- 771. The longest consecutive character in a string
猜你喜欢
Paddlenlp text classification based on ernir3.0: take wos dataset as an example (hierarchical classification)
STM32 board level support package for keys
[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN
What are the main functions and uses of LCR tester
Att & CK preliminary understanding
Solve Jupiter: the term 'Jupiter' is not recognized as the name of a cmdlet, function, script file
npm ERR code ETIMEDOUT npm ERR syscall connect npm ERR errno ETIMEDOUT npm ERR network reques...
基于Ernie-3.0 CAIL2019法研杯要素识别多标签分类任务
PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
Summary of common error types in JS
随机推荐
Remember the first line segment tree (corresponding to Luogu 3372)
Analysis notes on let (const) temporary dead zone in JS
PaddleNLP基于ERNIR3.0文本分类以中医疗搜索检索词意图分类(KUAKE-QIC)为例【多分类(单标签)】
[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN
Which is the file transfer command in the basic services of the Internet
STM32 - reset and clock control (cubemx for clock configuration)
静态成员static详解
(翻译)图技术简明历史
96. Different binary search trees (medium binary search tree dynamic planning)
Solve Jupiter: the term 'Jupiter' is not recognized as the name of a cmdlet, function, script file
PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
6K6w5LiA5qyh5pS75Ye75YiG5p6Q
20-09-27项目迁移到阿里折腾记录(网卡顺序导致服务无法通过haproxy连接到db)
76. Minimum coverage substring (hard sliding window hash table string)
SSH password free login
What is time complexity
6K6w5LiA5qyh5pS75Ye75YiG5p6Q
STM32CUBEIDE(10)----ADC在DMA模式下扫描多个通道
How to install WiFi correctly
STM32 board level support package for keys