Framing error generated after RS485 plugging and unplugging
Hello everyone, I encountered a problem while using STM32L431 for RS485 development. I used the ISO7041 isolation chip, and in the initial state, the DE pin is low, while both TX and RX are high. The current issue is that when I turn on the power, reset, and plug in 485, both the transmission and reception of 485 are normal. However, when I unplugged and inserted 485 again, an FE error occurred. Why is this? Is it because the voltage level does not match after inserting 485?

Debugging found errorsflags=2, which should be FE errors。
Here is some of my code:
int main()
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_LPUART1_UART_Init();
HAL_GPIO_WritePin(DE485_GPIO_Port, DE485_Pin, GPIO_PIN_RESET);
initSqQueue(&uart[_LPCOM].Rx, lpuartRxBuff, sizeof(lpuartRxBuff));
initSqQueue(&uart[_LPCOM].Tx, lpuartTxBuff, sizeof(lpuartTxBuff));
__HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_RXNE);
__HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_IDLE);
while(1)
{
Process_Modbus_Receive(_LPCOM); // MODBUS
}
}
void USER_LPUART1_IRQHandler(void)
{
uint8_t lpuart1_data;
if (__HAL_UART_GET_FLAG(&hlpuart1, UART_FLAG_RXNE) != RESET)
{
lpuart1_data = (uint8_t)hlpuart1.Instance->RDR & (uint8_t)0x00fff;
wrEleQueue(&uart[_LPCOM].Rx, lpuart1_data);
uart[_LPCOM].active = true;
}
if (__HAL_UART_GET_FLAG(&hlpuart1, UART_FLAG_IDLE) != RESET)
{
uart[_LPCOM].rxIdle = true;
__HAL_UART_CLEAR_IDLEFLAG(&hlpuart1);
}
else
{
uart[_LPCOM].rxIdle = false;
}
}
void LPUART1_IRQHandler(void)
{
USER_LPUART1_IRQHandler();
HAL_UART_IRQHandler(&hlpuart1);
}
My current solution is to modify the HAL library generated by CUBEMX, directly delete the judgment of CR3 EIE value and clear the flag bit. Is this correct? Will it affect the transmission and reception of other serial ports, or can this flag be detected elsewhere and cleared elsewhere.
// if (((isrflags & USART_ISR_FE) != 0U) && ((cr3its & USART_CR3_EIE) != 0U))
if (((isrflags & USART_ISR_FE) != 0U) )
{
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_FEF);
huart->ErrorCode |= HAL_UART_ERROR_FE;
}


