Computer Science论文模板 – Microprocessor System Design Laboratory

In this lab, several experiments were conducted to explore and understand the usage of USART and related configurations on the STM32 microcontroller development board. The experiments can be itemized as follows:

  • Experiment 1: Verifying USART Configuration
  • Experiment 2: Initializing USART1 and Sending Data
  • Experiment 3: Implementing String Printing Function
  • Experiment 4: Configuring UART Using Registers

The experiments led to valuable insights into USART, register operations, ASCII codes, string handling, and function implementation in the context of STM32. Overall, this lab provided a comprehensive understanding of USART and code encapsulation techniques for practical engineering applications.

Experiment 1: Verifying USART Configuration

  • Design

In the first experiment, the focus was on understanding the configuration processes and code meanings associated with SysClock and USART. This involved validating the calculated configuration code against the parameters outlined in the experiment requirements. Subsequently, the generated code was downloaded to the development board for functional verification, resulting in the expected outcomes.

  • Result

The code successfully compiled and executed, with the cyclic appearance of the letters ‘A’ and ‘B’ in eagleCOM. Screenshots of the code with line-by-line annotations are provided below:

  • Questions

When the parameter of the Delay function was changed from 50000 to 100, the resulting wait time became significantly shorter. As a consequence, the data from the first transmission was still in the process of being sent when the second data transfer began, leading to potential data corruption and the possibility of encountering garbled characters.

Experiment 2: Initializing USART1 and Sending Data

  • Design

In this experiment, the primary objective was to complete the initialization of USART1. It is essential to note that USART1 and USART2 have distinct RST registers, which required differentiation. Additionally, the experiment involved calculating a 72MHz clock frequency based on the prescaler factor and routing it to the APB2 bus. Furthermore, the student account number “120090889” was converted into its corresponding ASCII codes and stored in USART1’s transmit register. As the student account was sent only once, the transmission operation needed to be placed outside the while loop. These steps were essential in achieving the experiment’s goals.

  • Result

Upon pressing the RESET button, eagleCOM successfully received my student account number, “120090889.” Below is the initialization code for USART1:

Experiment 3: Implementing String Printing Function

  • Design

In this experiment, a string printing function was introduced to achieve two primary objectives. Firstly, it was designed to check whether a string has reached its end, which involves determining whether the last character in the string is ‘\0’ (null terminator). Secondly, the function aimed to monitor the TXE register in the SR (Status Register) to assess the successful transmission of data. The combination of these two functionalities allowed for a more accurate implementation of string transmission.

  • Result

Within eagleCOM, the string “1234567890” was successfully visible. The code is depicted in the following figure:

Experiment 4: Configuring UART Using Registers

  • Design

Utilizing a register-based approach, the study focuses on the modification of UART configuration. Enclosed below are the encapsulated code snippets for both UART configuration and Clock configuration

  • Result

USART1 successfully received the string ‘1234567890,’ while USART2 received the string ‘120090889’.


In this experiment, several key insights were gained:

  • Fundamental Understanding of USART: USART (Universal Synchronous/Asynchronous Receiver/Transmitter) is a commonly used serial communication interface in microprocessors. It supports both synchronous and asynchronous communication and allows for full-duplex communication.
  • Register Operations: In embedded systems, hardware devices are often controlled by manipulating registers. In the case of USART, there are various related registers to configure, such as data registers, control registers, and baud rate registers.
  • ASCII Codes and Strings: ASCII (American Standard Code for Information Interchange) is a widely used character encoding standard, primarily for representing English characters. Strings are sequences composed of characters.
  • Function Implementation: To transmit strings, a function must be developed. This function iteratively calls the USART transmit function to send the ASCII codes of each character in the string. The function takes a string as an input parameter.

Overall, this experiment provided a good understanding of working with USART in the context of STM32 microcontrollers and how to encapsulate code for engineering applications.

Scroll to Top