你好,原子哥。我想使用中断uart,可是失败了。 我的代码为: void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { if(huart == &huart2){ RxBuff[RxCount++]=RxByte; printf("get c RxBuff %c:\r\n",RxBuff[RxCount]); printf("get c RxByte %c:\r\n",RxByte); if(RxByte==0x0A)// \r\n { //HAL_UART_Transmit_IT(&huart2,RxBuff,RxCount); RxCount=0; Rxflag=1; printf("1\r\n"); } else if(RxCount>=254) { RxCount=0; printf("2\r\n"); } HAL_UART_Receive_IT(&huart2,&RxByte,1); printf("huart2 read\r\n"); } if(huart == &huart1){ printf("huart1 raed\r\n"); } } 我在串口助手上面发送hello,到开发板, 结果打印出: get c RxBuff *: get c RxByte h: huart2 read get c RxBuff *: get c RxByte e: huart2 read 在 while函数前已经HAL_UART_Receive_IT(&huart2,&RxByte,1); 配置环境为:Keil.STM32F1xx_DFP.2.1.0 请问是什么原因呢?
|