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);
即爲接受中斷處理函數。