RS485正确调用方式
HAL_UART_Receive_IT(&huart3, RxBuffer,MAX_RX_BUFFER_SIZE);
HAL_UARTEx_ReceiveToIdle_IT(&huart3,RxBuffer,MAX_RX_BUFFER_SIZE);//两次激活
while (1)
{
HAL_UARTEx_ReceiveToIdle_IT(&huart3,RxBuffer,MAX_RX_BUFFER_SIZE);//重复激活
if (UART_Size > 0)
{
LED_Y(1);
Process_UART();
}
LED_Y(0);
}
//在中断里激活一次
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
//printf("IDLE callback IN\r\n");
if (huart->Instance == USART3){
UART_Size = Size;
HAL_UARTEx_ReceiveToIdle_IT(&huart3,RxBuffer,MAX_RX_BUFFER_SIZE);
}
}
无论何时重启都可以挂入
1.删除HAL_UART_Receive_IT(&huart3, RxBuffer,MAX_RX_BUFFER_SIZE);
仍然正常响应
2.删除HAL_UARTEx_ReceiveToIdle_IT(&huart3,RxBuffer,MAX_RX_BUFFER_SIZE);
仍然正常响应
3.均删除
仍然正常响应
4.删除主循环中的HAL_UARTEx_ReceiveToIdle_IT(&huart3,RxBuffer,MAX_RX_BUFFER_SIZE);
数据发送时仍然正常响应,但重启后再给入数据不再正常响应,这里就是最大的问题
标签:HAL,记录,BUFFER,huart3,RS485,RX,问题,RxBuffer,SIZE From: https://www.cnblogs.com/aker-whale/p/18341784