stm32 study notes--serial port baud rate

Publisher:sunyouz1Latest update time:2015-09-10 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
What are the problems with the study these days? When I started to look at the first few routines, I seemed to find some feelings and learned some things, such as how to calculate the baud rate that the serial port needs to configure, how to implement the addressing operation of a single bit of the I/O port through the design of the bit band alias area, how to set the port mode, and the respective advantages and disadvantages of spi and iic. I read so much last week, and now I think that these are the only ones left. Then this week, the feeling of this week is even less solid. Many things are just a cursory glance and forgotten after reading, such as interrupt control. It was not until the second time that the framework was formed, the various experiments of watchdog DMA game controller infrared communication, well, I only know what these things are, and my understanding of them is not even as good as the modules of last week. At least there is a framework. At this point, there is only "Oh, this, I know..." and that's it, right! That's it. So the next step is to modify the program, no matter what program you modify, of course it is best to modify the program of the three-axis accelerometer directly, modify it casually, and you can see the effect on the board after the modification. Do this kind of thing. If there is nothing to modify in this module, modify something else. Anyway, you have to start modifying it. You can't just look at it like this. Okay, let's try it tomorrow.
 
 
Below I will organize what I can still remember.
1. How is the baud rate of the serial port configured?
Each serial port of STM32 has an independent baud rate register USSART-BRR. By setting this register, you can achieve the purpose of configuring different baud rates. Of course, the key is how much the baud rate should be set. Because first of all, we should know why we need to configure the baud rate. The following is the answer found by Baidu
 
 
The baud rate of microcontroller serial communication is the interval between two data transmissions, or the number of bytes sent per second. When you are performing serial communication, two microcontrollers must communicate, so they must be synchronized (the baud rate must be the same), otherwise the communication cannot be established.
 
 
That is to say, the baud rate cannot be set arbitrarily, and needs to be coordinated with the chip. After we know the baud rate, we need to express it in a register, which involves the calculation mentioned at the beginning. The lowest four bits of USART-BRR are used to store the decimal part, the next 12 bits are used to store the integer part, and the highest 16 bits are not used. The calculation formula is as follows
 
USARTDIV = PCLK2 / (serial port baud rate * 16). In this way, the value of USARTDIV can be calculated, and then converted into binary and put into the register to complete the setting of the serial port baud rate.
Keywords:stm32 Reference address:stm32 study notes--serial port baud rate

Previous article:stm32 study notes--spi and iic
Next article:STM32 low power design experience

Recommended ReadingLatest update time:2024-11-16 21:32

STM32 SysTick routine
#include "stm32f10x.h"   /*RCC clock configuration*/ void RCC_config() {  ErrorStatus HSEStartUpStatus;   /* RCC registers are set to default configuration */ RCC_DeInit(); /* Turn on external high speed clock */ RCC_HSEConfig(RCC_HSE_ON); /* Wait for the external high-speed clock to stabilize*/ HSEStartUpStat
[Microcontroller]
How to confirm whether the STM32 clock configuration is correct
Configure STM32F103 clock (HSI) to 48M void SystemClock_Config(void) {     RCC_DeInit();     RCC_HSICmd(ENABLE);     while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);     RCC_HCLKConfig(RCC_SYSCLK_Div1);          RCC_PCLK1Config(RCC_HCLK_Div2);     RCC_PCLK2Config(RCC_HCLK_Div1);       RCC_PLLConfig(RCC_PLLS
[Microcontroller]
Another entry-level embedded development platform! Mir STM32MP135 core board new product release
Another entry-level embedded development platform! Mir STM32MP135 core board new product release Since STMicroelectronics (ST) launched the first STM32 Cortex-M core MCU in 2007, ST has been developing rapidly in the field of MCU for more than a decade. In 2019, ST released the new STM32MPU series pro
[Embedded]
Another entry-level embedded development platform! Mir STM32MP135 core board new product release
Understanding the startup code of the medium-capacity STM32 processor
Today I want to introduce the startup code of STM32. I am using the medium-capacity STM32f103c8t6 here. The corresponding startup file is startup_stm32f10x_md.s. My startup file version is V3.6.2 Without further ado, here are the source codes I annotated:   /**   ***************************************************
[Microcontroller]
STM32--UART asynchronous communication learning
Description of the character transmission process: In the UART transmission process, the data is first input into the transmission data register (TDR). At this time, (TXE) is set to 1 by hardware. Then the TDR register serially shifts the data into the transmission shift register and transmits the data at the TX port.
[Microcontroller]
STM32--UART asynchronous communication learning
STM32 BOOT0, BOOT1 configuration
STM32 has three boot modes: main memory, system memory and internal SRAM. You can find them in the user manual of the chip. Regarding these three startup modes, they are as follows: BOOT1=x, BOOT0=0: boot from main memory, which is the on-chip Flash memory of 64K, 128K, 256K, 512K, etc. Under normal circumstances, w
[Microcontroller]
stm32 i2c communication [operation register + library function]
The I2C bus was designed by NXP (formerly PHILIPS) and has a very concise physical layer definition. Its characteristics are as follows: Only two bus lines are required: a serial data line SDA and a serial clock line SCL; Each device connected to the bus can be software-addressed by a unique address and a simple mas
[Microcontroller]
A technical expert made his own STM32 development board to learn 32-bit microcontrollers (pictures and text)
The lab is about to close, so I made the STM32 development board I always wanted to make, and also made the 2.4-inch TFT adapter board and added a touch screen. I uploaded my information here. I hope it will be helpful to netizens. I always put practicality first, and this time is no exception. The development
[Microcontroller]
A technical expert made his own STM32 development board to learn 32-bit microcontrollers (pictures and text)
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号