Cube配置
USART配置
- 在Connectivity中选中USART1
MODE = Asynchronous
Hardware Flow Control = Disable - Parameter Settings中配置
Baud Rate = 115200
Word Length = 8bit
Parity = None
Stop Bits =1
Data Direction = Receive and Transmit
Over Sampling = 16 Samples - NVIC Setting
勾选Enable,Preemption Priority =2 - 生成代码
修改代码
- 生成代码后,即可使用
HAL_UART_Transmit_IT(&huart1 ,(uint8_t*)aTxStartMessages,sizeof(aTxStartMessages));
函数去发送数据。
- 弱定义函数
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
即为接受中断处理函数。