51 Baud Rate Generator Timer Initial Value Calculation Method

Publisher:fuehrd努力的Latest update time:2017-11-11 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In mode 0 and mode 2, the serial port baud rate is fixed, mode 0 is Fosc/12, mode 2 is Fosc/32 or Fosc/64, which is determined by the SMOD bit of the PCON register.

In mode 1 and mode 3, the baud rate is a variable value. The baud rate can be generated by timer 1 (8052 can be generated by timer 2). So what is the baud rate? The baud rate is determined by the overflow rate of timer 1:
Baud Rate = (2SMOD/32)*(Timer 1 Overflow Rate)
Note: 2SMOD Here SMOD is the exponent, SMOD is the baud rate double baud rate bit, which is in the PCON register.
When using timer 1 as a baud rate generator, it is usually necessary to configure timer 1 to the 8-bit auto-reload mode, and at the same time disable timer 1 interrupts. So how is the overflow rate of timer 1 calculated? The overflow rate is the overflow frequency. Assuming the crystal frequency is 12MHz and the TH1 value is 0xFE, it only takes two clock pulses to overflow, and the overflow period is 2us, so the overflow frequency is 500KHz. According to the timer section, the timing time is calculated as follows:
Timing time = (maximum count value - counter initial value) * machine cycle = (maximum count value - counter initial value) * (12/crystal frequency (Hz)) (s) = (256-TH1) * (12/OSC_FREQ (Hz)) (s).
Then the overflow frequency is naturally:
OSC_FREQ (Hz) / ((256-TH1) * 12).
So the final baud rate is:
(2SMOD / 32) * (OSC_FREQ (Hz) / ((256-TH1) * 12)).

Now that we have the formula for calculating the baud rate, we can naturally deduce the initial value of TH1 based on the baud rate:
BAUD_RATE=(2SMOD/32)*(OSC_FREQ(Hz)/((256-TH1)*12))
32*12*(256-TH1)=(2SMOD*OSC_FREQ(Hz))/BAUD_RATE
256-TH1=(2SMOD*OSC_FREQ(Hz))/(BAUD_RATE*32*12)
TH1=256-(2SMOD*OSC_FREQ(Hz))/(BAUD_RATE*32*12)
Assuming the crystal frequency is 11.0592MHz, the baud rate is 9600, and SMOD=0, what should the initial value of TH1 be? According to the above formula, we can calculate that TH1=256-11059200/(9600*32*12)=0xFD.


Reference address:51 Baud Rate Generator Timer Initial Value Calculation Method

Previous article:51 MCU interrupt priority setting
Next article:51 MCU internal EEPROM reading and writing analysis and routines

Recommended ReadingLatest update time:2024-11-16 14:37

51 MCU storage organization
The memory organization structure of MCS-51 single chip microcomputer Features: Harvard structure, program memory and data memory are separated, each has an independent 64K (0x0000 ~ 0xFFFF) addressing space (to be precise, internal data memory and external data memory are not the same thing). Program Memory: ① U
[Microcontroller]
51 MCU timer and counter explanation
In real life, such as product counting, speed measurement, time control and many other occasions, the functions of timers and counters are often needed. The 8051 microcontroller has two built-in timers and counters, which can be used to achieve timing and counting functions. Let's learn about the timers and counters i
[Microcontroller]
51 MCU timer and counter explanation
Analysis of the calculation method of stack in MCS51 single chip computer programming
Using C language to program MCS51 series microcontrollers is an inevitable trend in the development and application of microcontrollers. Keil's C51 compiler supports the classic 8051 and 8051 derivatives, commonly known as Cx51. It should be said that Cx51 is an extension of C language on MCS51 microcontrollers. It ha
[Microcontroller]
Analysis of the calculation method of stack in MCS51 single chip computer programming
MCU STM8L051F3xx EEPROM Operation Notes
MCU: STM8L051F3xx EEPROM Address: 0x00 1000 ~ 0x00 10FF, 256 Bytes Simple operation instructions:  EEPROM is write-protected after power-on reset. When writing data to it, it is necessary to unlock and turn off the write protection. The unlocking process is: 1. Write the key 0xAE to FLASH_DUKR for the first time 2
[Microcontroller]
16*16LED dot matrix display controlled by 89c51
#include AT89x51.H tZqy \_G   unsigned int zimo,xx=0; //zimo is the character counter, xx is the number of characters when the screen is split. /. 2 I   unsigned char yid,h; //yid is the movement counter, h is the line counter t182 &gpd`   unsigned char code hanzi ; //Chinese character font J rm 9,7/   unsigned char
[Microcontroller]
51 MCU IO port simulation serial communication 3-interrupt method
Hardware environment: STC89C52 Software environment: IDE Keil uVision V4.10 Compiler C51 V9.0 code show as below: /************************************************** Method 3: Interruption method Hardware: 11.0592MHz crystal, STC89C52, RXD P1.0 TXD P1.1 Baud rate: 9600 Description: The so-called interrupt meth
[Microcontroller]
Application of MCS51 microcontroller in data acquisition and monitoring system
1 Introduction The standard configuration of the MCS51 microcontroller has only one set of full-duplex UART serial ports, P3.0-RXD for reception and P3.1-TXD for transmission. If you want to complete multiple serial port transceivers, you generally use an external expansion chip, such as: GM8123/25, to complete Expand
[Microcontroller]
USB printer driver design for 80C51 and CH375
Introduction:   This topic comes from a project of Beijing Puji General Company. Since the company’s existing stand-alone spectroscopic instrument products (such as 1810, T6, etc.) use parallel port printing technology, and with the gradual popularization of USB printer technology, parallel port printers are becoming
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号