And again: Incorrect handled UART overrun error in stm32f4xx_hal_uart.c
I have to design a special USB <-> RS485 converter using an STM32F401.
I realized the project at first with a STM32F4071G eval board with DMA supported USART functions and without RTOS using STM32Cube with FW-F4_V1.25.1 and all worked fine.
After porting the software to a Nucleo eval board with the target MCU STM32F401 the transfer from RS485 to USB also works perfect up to baudrates of 115200 and kilobytes of data per shot.
But from USB to RS485 after sending all data correct to the RS485 port the UART overrun ISR is called and the HAL remains in a permanent loop to resend the data getting now immediately the overun error and can only stopped by a reset.
The error occurs independent from baudrate (I tried it down to 300) and byte count. If I send only one byte over USB it crashes in the same manner as if sent 64 bytes (the maximal number of bytes for one USB transfer). The data will all be transfered and reach the RS485 device but the HAL_UART_TxCpltCallback will not be called than but the overrun interrupt.
I searched meanwhile here in the community and in the internet for a solution. But although this issue often was reported (especially for the STM32-HAL) by different users nowhere a solution was proposed.
The system clock is set to 84MHz, the APB1 peripheral clock to 42MHz. I can understand if in case of a slow MCU a overrun error may occur when receiving data from UART. But how this can occur when sending only one byte of data supported by DMA over UART? And how can I prevent the HAL from the permanent and senseless try to send the data again?
