Serial communication knowledge points summary

Publisher:导航灯Latest update time:2016-05-17 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The first thing that is closely related to serial port programming is various registers. Then sort out the communication methods under various serial port communication modes. Then paste the calculation formula of baud rate. As for MAX232, TMOD, TCON and other registers, they should be another knowledge point. TMOD and TCON have been noted before. The knowledge points that have not been noted will be summarized after they are used. The current superficial realm is: use-->learn-->use--->summarize, and the path of serial communication is also like this.

 

1. Serial port control register SCON

2 Power Management Register PCON

3 Introduction to Serial Port

4 Baud rate

(1) Definition

The speed at which a microcontroller or computer communicates over a serial port is expressed in baud rate, which is defined as the number of bits of binary code transmitted per second.

Practical knowledge points  The maximum distance of serial information transmitted directly by the serial interface or interrupt is also related to the transmission rate and the electrical characteristics of the transmission line. When the transmission line uses an unbalanced shielded twisted pair with a 50pf capacitor per 0.3m, the transmission distance decreases as the transmission rate increases. When the bit rate exceeds 1000bps, the maximum transmission distance drops rapidly. For example, at 9600bps, the maximum distance drops to only 76m. Therefore, when we choose a higher rate to transmit data in a serial port communication experiment, we should try to shorten the length of the data line. In order to ensure safe data transmission, do not use too long a data line at a lower rate. Generally speaking, the higher the transmission rate, the smaller the maximum transmission distance of the line. 

 

(2) Calculation of baud rate

The 51 single-chip microcomputer serial port has four working modes. The baud rate of mode 0 and mode 2 is fixed, while the baud rate of mode 1 and mode 3 is variable, which is determined by the overflow rate of timer T1.

 

The four working modes of the serial port correspond to three baud rates. Since the input shift clock sources are different, the calculation formulas for various baud rates are also different:

Mode 0 baud rate = f(osc)/12

Mode 1 baud rate = (2^SMOD/32) * (T1 overflow rate)

Mode 2 baud rate = (2^SMOD/64) * f(osc)

Mode 3 baud rate = (2^SMOD/32) * (T1 overflow rate)

 

f(osc) is the system crystal oscillator frequency, SMOD is the highest bit of the PCOM register, which is either 0 or 1; T1 overflow rate is the frequency of timer T1 overflow.

 

All knowledge points and notes are sourced from "New Concept 51 MCU C Language Tutorial" by Guo Tianxiang

 

This note record is complete.

Reference address:Serial communication knowledge points summary

Previous article:Solution to the failure of downloading hex file to MCU
Next article:51 MCU RAM data storage area

Latest Microcontroller 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号