I'm using USART with DMA and when I disconnect the Rx cable, sometimes the communication resumes and sometimes not. How can I always recover USART Rx?
I tries reseting it with RCC using the line:
RCC->APB2RSTR ^= RCC_APB2RSTR_USART1RST; // USART1
But I couldn't even receive data by USART, I'm not sure how to use it.
You might have to check and clear any noise, framing, or other error statuses from the Rx side of the USART
You'd have to transition the reset bit twice to get a reset pulse to the peripheral.
You can disable UART error interrupts right after init:
CLEAR_BIT(huartPtr->Instance->CR3, USART_CR3_EIE); CLEAR_BIT(huartPtr->Instance->CR1, USART_CR1_PEIE);
but also I use software CRC32 and auto-retry for data transfers.