What is the principle of UART serial communication?

Publisher:真诚相伴Latest update time:2022-12-05 Source: elecfansKeywords:uart Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

What is the UART communication protocol?
As an asynchronous serial communication protocol, UART works by transmitting each character of the transmitted data one by one. The meaning of each bit is as follows:
Start bit: First send a logic "0" signal to indicate the start of character transmission.
Data bit: Immediately after the start bit. The number of data bits can be 4, 5, 6, 7, 8, etc., to form a character. Usually ASCII code is used. Transmission starts from the lowest bit and is positioned by the clock.


Parity bit: After adding this bit to the data bit, the number of "1" bits should be an even number (even parity) or an odd number (odd parity) to verify the correctness of data transmission.


Stop bit: It is a sign of the end of a character data. It can be 1 bit, 1.5 bit, or 2 bit high level. Because the data is timed on the transmission line, and each device has its own clock, it is very likely that there will be a small desynchronization between the two devices during communication. Therefore, the stop bit not only indicates the end of the transmission, but also provides the computer with an opportunity to correct the clock synchronization. The more bits applicable to the stop bit, the greater the tolerance for different clock synchronization, but the slower the data transmission rate.


Idle bit: in the logic "1" state, indicating that there is no data transmission on the current line.


Working principle of UART serial communication
(1) Data transmission process
Idle state, the line is at a high level; when receiving the send command, the line is pulled down for a data bit time T, and then the data is sent in sequence from low to high. After the data is sent, the parity bit and stop bit are sent, and a frame of data is sent.
(2) Data reception process:
Idle state, the line is at a high level; when the falling edge of the line is detected (high level changes to low level), it means that the line has data transmission. According to the agreed baud rate, the data is received from low to high. After the data is received, the parity bit is received and compared to see if it is correct. If it is correct, the subsequent device is notified to receive the data or store it in the buffer.
Since UART is asynchronous transmission and there is no transmission synchronization clock, in order to ensure the correctness of the data, UART uses a clock of 16 times the data baud rate for sampling. Each data has 16 clock samples, and the middle sampling value is taken to ensure that the sampling will not slip or error. Generally, the number of data bits in a UART frame is 8, so even if there is a clock error in each data, the receiving end can still sample the data correctly.


The timing of receiving data of UART is: when the falling edge of data is detected, it indicates that there is data to be transmitted on the line, and the counter CNT starts counting. When the counter is 24=16+8, the sampled value is the 0th bit of data; when the counter value is 40, the sampled value is the first bit of data, and so on, the next 6 data are sampled. If parity check is required, when the counter value is 152, the sampled value is the parity bit; when the counter value is 168, the sampled value is "1" indicating the stop bit, and data reception is completed.

Keywords:uart Reference address:What is the principle of UART serial communication?

Previous article:What is the FOC control algorithm?
Next article:Application of frequency converter in hot rolling bar line mill

Recommended ReadingLatest update time:2024-11-16 12:42

S3C6410 bare metal UART driver (redefine printf to serial port)
To ensure that S3C6410 has been initialized, usually use UBOOT initialization   //Serial port register //UART0 #defineULCON0 *((vu32*)0x7F005000) //UART channel 0 line control register #defineUCON0 *((vu32*)0x7F005004) //UART channel 0 control register #defineUFCON0 *((vu32*)0x7F005008) //UART channel 0 FIFO control r
[Microcontroller]
S3C2440 processor UART dedicated registers
Here we only introduce the most commonly used registers related to UART. As for the registers with other functions involved in programming, they are not introduced here. 1.ULCONn(n=0,1,2) //Checksum mode register     0=Normal mode, 1=Infrared mode     0XX=No check, 100=Odd check, 101=Even check     0=1 stop bit, 1=2
[Microcontroller]
UART interface to control LED lights
1. The serial port receives data in query mode, and displays the data on the PB port and returns it. 2. The internal 1M crystal oscillator, the program uses a single task mode, and the software delays. 3. To conduct this experiment, please plug in all 8 short-circuit blocks of JP1 and the short-circuit block of JP7 (L
[Microcontroller]
S3C2440 UART Operation (FIFO Mode)
background knowledge: 1 Since the baud rate setting of UART is related to the clock, this article sets FCLK:HCLK:PCLK=1:2:4, FCLK=200MHZ, so the clock setting is introduced first. It is generally believed that PLL is unstable after power-on reset. Therefore, Fin replaces MPLL and directly supplies Fclk before soft
[Microcontroller]
S3C2440 UART Operation (FIFO Mode)
STC15F2 series MCU UART1 uses timer 1 as baud rate generator
#include reg51.h #include "main.h" #include "intrins.h" //Use T2 timer 2 to control the baud rate of serial port 1 #define FOSC 18432000L //System frequency #define BAUD 9600 //Serial port 1 baud rate #define TM2 (65536-(FOSC/4/BAUD)) #define NONE_PARITY 0 //No parity #define ODD_PARITY 1 //Odd parity #define E
[Microcontroller]
51 MCU UART serial communication
Use half-duplex communication /************************************      Using the hardware UART module and serial port interrupt  ************************************/   #include reg52.h       typedef unsigned int uint;      void configUART(uint baud);      void main() {       EA = 1;       configUART(
[Microcontroller]
【ARM】Serial communication·FS2410·Bare metal UART
Development Environment (1) Hardware platform: FS2410 (2) Host: Ubuntu 12.04 Schematic diagram of FS2410 serial port Serial UART register configuration Configure TXD0 and RXD0 (GPH2, GPH3) Set Baud Rate (UBRDIVn) Set the transmission format (ULCONn) Select clock source and interrupt mode
[Microcontroller]
【ARM】Serial communication·FS2410·Bare metal UART
Study Notes--stm8 UART Serial Port
ST 3 in 1 development board stm8 learning uart Author:Xiao Xing Program features: Accept the value entered by the HyperTerminal and display it I have to talk about the clock problem last time. Because you may rarely see the clock configuration part later, it is necessary to clarify the status during initialization--
[Microcontroller]
Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号