2014-12-18 08:00 AM
When debugging some code that uses DMA to receive data from an uart i noticed that if for some reason an overrun error happen, it's not taken into account, and that prevents the DMA transfer complete interrupt to ever occur.
The problem shows up if i hit a breakpoint in my program after a DMA receive has been issued. When execution is frozen *if data are sent by the remote side* an overrun error is signaled in the UART register. I figure that is to be expected, but when looking at HAL_UART_Receive_DMA() (in stm32F4xx_hal_uart.c) it turns out the UART error interrupt is never enabled, so there's no code to clear the error flag and call the XferErrorCallback... Basically, during DMA transfer with HAL_UART_Receive_DMA(), if something goes wrong on the UART that's unrelated to DMA (noise / framing error / overrun), there's no way to know... and all communication stops working. This looks like a bug to me (or well, something that's been overlooked), but maybe i'm missing something? #uart-dma-overrun2015-01-12 07:30 AM
Hi,
This is a normal behavior, you should avoid to set breakpoint in your code. In addition, The PPP error interrupts are not supported by HAL PPP_DMA_Process().Regards,Heisenberg.2015-03-02 04:55 AM
I am having the same issue. `USART1_SR -> ORE` bit is set when `HAL_UART_Receive_DMA` is called.
huart->State = HAL_UART_STATE_BUSY_RX, but is never reset because of the overrun error.
I receive the same overrun error in IT mode, which calls the error callback.Surely this is a bug?2016-01-20 01:15 PM
I had the same issue. The HAL was stuck in the state
HAL_UART_STATE_BUSY_RX
with no indication of error. The problem turned out to be overrun (not an overrun resulting from a breakpoint, by the way). To improve the HAL, the overrun condition could be detected in HAL_UART_Receive_DMA() and returned in the status. The bit can also be tested and cleared before the Receive call using__HAL_UART_CLEAR_FLAG(&huart1, UART_CLEAR_OREF)
To ignore overruns, I tried initializing with the overrun disable advanced featurehuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;
That feature its own bug in the HAL. The bug is in stm32f3xx_hal_uart.c v1.2.0 line 1691. The incorrect line isMODIFY_REG(huart->Instance->CR3, USART_CR3_OVRDIS, huart->AdvancedInit.OverrunDisable);
The corrected line isMODIFY_REG(huart->Instance->CR3, USART_CR3_OVRDIS, UART_ADVFEATURE_OVERRUN_DISABLE);