How to Reset an UART after an error
Hi,
Recently, we desighed a test board with STM32F103RB for UART communication with a wireless chip, and we found that the HAL_UART_ErrorCallback is triggered occasionally (the periods of errors vary betweent tens of minutes to hundreds of minutes), the error does not affect sending data from STM32F103RB to the wireless chip, but once an error occurs, the MCU does not receive any data from the wireless chip any more, at the moment, we have to reset the MCU to resolve this issue. However, we would like to reset the UART to resolve the issue if possible as there are some other tasks running on the MCU.
We tried the following, but it does not work:
HAL_UART_Abort_IT(uart);
HAL_UART_DeInit(uart);
uart->Instance = USART3;
uart->Init.BaudRate = WirelessUartBaudRate;
uart->Init.WordLength = UART_WORDLENGTH_8B;
uart->Init.StopBits = UART_STOPBITS_1;
uart->Init.Parity = UART_PARITY_NONE;
uart->Init.Mode = UART_MODE_TX_RX;
uart->Init.HwFlowCtl = UART_HWCONTROL_NONE;
uart->Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(uart);
What is the correct way to do this?
Many thanks to any suggestion.
Chao
