【stm32】hal库学习笔记-UART/USART串口通信
hal库驱动函数
CubeMX图形化配置
导入LCD.ioc
RTC设置
时钟树配置
设置LSE为RTC时钟源
USART设置
中断设置
程序编写
编写主函数
/* USER CODE BEGIN 2 */
lcd_init();
lcd_show_str(10, 10, 16, "Demo12_1:USART1-CH340", RED);
lcd_show_str(10, 30, 16, "Please connect board with PC", RED);
lcd_show_str(10, 50, 16, "via MiniUSB line before power on", RED);
uint8_t hello1[] = "Hello, blocking\n";
HAL_UART_Transmit(&huart1, hello1, sizeof(hello1), 500);
HAL_Delay(10);
uint8_t hello2[] = "Hello, none blocking\n";
HAL_UART_Transmit_IT(&huart1, hello2, sizeof(hello2))