(3) Lanqiao Cup Embedded——Serial

(1) Personal habits

A separate USART.c and USART.h will be created and placed under the HARAWARE folder

(2) Preparation

1. Lanqiaocup embedded board cannot directly use serial port 1, so here is the experiment with serial port 2.
2. Add library file: stm32f10x_uasrt——> there are library functions about serial port configuration
3. Add library file: stm32f10x_rcc ——>About Interrupt configuration related library functions
Insert picture description hereInsert picture description here

(3) Write void USART_init(u32 bound) initial function

Insert picture description here

(4) Write void USART2_Send(u8 *str) sending function

Insert picture description here

(5) Write void USART2_IRQHandler(void) receiving function

Insert picture description here

(6) Write void USART2_Purging(void) clear function

Insert picture description here

(7) Write serial port data processing function

Insert picture description here

(8) Problem

Question one:
Where can I find the interrupt channel corresponding to the serial port interrupt in the interrupt configuration?
#include “stm32f10x.h” in the smt32 header file

Question two·:
Function Wait for the data transmission to be completed, and the TXE bit will be set to 1 after the data transmission is completed
Insert picture description here
Question three:
It can be found under the file in the picture below
Insert picture description here
Question four:
The disability is to process the data well before proceeding to the next reception process to prevent confusion

Guess you like

Origin blog.csdn.net/m0_46278925/article/details/113337783