STM32CubeIDE 串口收发
1、配置RCC
2、配置时钟
3、配置JTAG
4、配置串口
4、重定向printf函数
在usart.c中添加以下内容
#include "stdio.h"
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1, (uint8_t*)&ch,1,HAL_MAX_DELAY);
return ch;
}
5、打印float设置
在主循环编写打印函数测试。