[STM32H5 development board] Chapter 6 CubeMx serial port printf test
[Copy link]
This post was last edited by Changjianze1 on 2023-5-13 22:36
Chapter 6 STM32H5 serial printf project
1. USART Hardware Selection
I really can't find the schematic diagram, I can only read the introduction of Nucleo
Select an onboard USART
Look at the data sheet for these two pins
2. USART Introduction
In the STM32 reference manual, the serial port USART (Universal Synchronous Asynchronous Receiver and Transmitter) is a serial communication device that can flexibly exchange full-duplex data with external devices. UART (Universal Asynchronous Receiver and Transmitter) is based on USART and has only asynchronous communication functions. The simple distinction between synchronous and asynchronous is to see whether a clock output is required during communication. The serial port communication we generally use is basically UART, that is, asynchronous UART, which needs to be paid attention to when generating projects later.
Look at the serial port characteristics of STM32H5
Three creation projects
Based on the previous project, the clock and other things are based on the previous 250M
Start serial port configuration directly
Generate Project
After generating the project, open the project and add a piece of code to main.c
Because I chose uart3 here
/* USER CODE END 0 */
int fputc(int ch, FILE *f)
{
HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 2);//huart根据你的配置修改
return ch;
}
I was struggling with this problem for dozens of minutes, and I couldn't solve it no matter what I did. I tried many solutions and modified the startup file, but it didn't work. The final solution was to just click Recompile.
Four test situations
|