当前位置:网站首页>How high does UART baud rate require for clock accuracy?

How high does UART baud rate require for clock accuracy?

2022-06-25 17:22:00 Tianwaifeixian CUG

1da1e53110c9f84f264ba5bc0b3a131f.png

A serial port communication (UART) It is an asynchronous communication , Both the sender and the receiver need to communicate according to the agreed baud rate . When baud rate error occurs , It will cause communication error . What are the factors that cause baud rate error , Today, let's analyze .

1. Frequency division error

First , The baud rate is generated according to the frequency division of the system clock , The relationship between the system clock and baud rate may not be an integer multiple , Therefore, there will be errors in frequency division . But now most of them MCU The system clock of is relatively high , Usually in the tens of MHz, Far greater than the baud rate of serial communication , So the effect of this error is very small . hypothesis MCU The clock is 48MHz, The baud rate is 115200,48MHz/115200=416.67, according to 417 frequency division , The actual baud rate is 48M/417=115108, Error is (115200-115108)/115200, about 0.08%, This error is very small , No effect on serial communication .

however , When the system clock is low , Or when the baud rate is high , That is, the difference ratio between the two is small , This error cannot be ignored .

For some earlier 51 Kernel MCU, Due to low operating frequency , Non integer crystal oscillator ( such as 11.0592M etc. ) To use the common baud rate ( such as 9600、115200), The error of frequency division shall be as small as possible .

2. Clock error

secondly , The main error of baud rate depends on the error of system clock . How high is the requirement for clock error in serial communication ?

First look at the serial port communication sequence diagram :

e0d0acb348dd32f5798bee2ff7802186.png

The serial port communication consists of the starting bit 、 Data bits 、 Check bit 、 Stop bit composition . With the common 8N1 For example , namely 1 Bit start bit ,8 Digit bit , No verification ,1 Bit stop bit . That is to say, transferring a byte requires 10bits. Each byte has a start bit for synchronization , So the error will only accumulate in one byte .

It's not hard to see. , At the last bit sampling , Maximum error , The allowable limit error is 0.5 position . Per byte 10 Bit calculation , The maximum allowable error is ±0.5/10=±0.05, namely ±5%. Considering that the serial communication involves both ends of the transceiver , There may be errors at both ends , therefore , The error at each end should be controlled within ±2.5% within .

When data bit 、 When there are many parity bits, etc , The required clock error is higher . Considering the above-mentioned frequency division error , Generally speaking , The clock error is less than ±2% when , Serial communication is reliable .

Recommended reading :

adopt STM32 Built in USB-DFU Download program

Several orders USB The scheme of converting to multiple serial ports

How to measure the running time of single chip microcomputer program ?

Several common methods of generating negative power supply

    Welcome to the official account " Development of Embedded Technology ", You can leave a message for me backstage . If you think the official account is helpful to you , Also welcome to recommend and share with others .

原网站

版权声明
本文为[Tianwaifeixian CUG]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251656146498.html