STMicroelectronics / stm32f4xx_hal_driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32F4 series.
BSD 3-Clause "New" or "Revised" License
109 stars 47 forks source link

an issue in using HAL_UARTEx_ReceiveToIdle_DMA #34

Open litesky opened 2 weeks ago

litesky commented 2 weeks ago

Describe the set-up STM32CubeF4 version: 1.28.0

Describe the bug missing call HAL_UARTEx_RxEventCallback in step 4.

How To Reproduce

Init uart rx dma in Circular mode.

HAL_UARTEx_ReceiveToIdle_DMA(huart, pData, 256);

send first 128 byte

1.DMA_IRQ -> UART_DMARxHalfCplt, _RxEventType = HAL_UART_RXEVENTHT -> HAL_UARTEx_RxEventCallback -> return (OK) 2.HAL_UART_IRQHandler, _RxEventType = HAL_UART_RXEVENTIDLE -> HAL_UARTEx_RxEventCallback -> return (OK)

send next 128 byte

3.DMA_IRQ -> UART_DMAReceiveCplt, RxEventType = HAL_UART_RXEVENT_TC -> HAL_UARTEx_RxEventCallback -> return (OK) 4.HAL_UART_IRQHandler -> return (Wrong)

Additional context https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/master/Src%2Fstm32f4xx_hal_uart.c#L2485-L2488 I think mcu call DMA cplt first, then call uart idle irq.

modify https://github.com/STMicroelectronics/stm32f4xx_hal_driver/blob/master/Src%2Fstm32f4xx_hal_uart.c#L2491-L2491 to && (nb_remaining_rx_data <= huart->RxXferSize)) maybe ok. Then HAL_UARTEx_RxEventCallback Size is 0.

KRASTM commented 2 weeks ago

Hello @litesky,

Thank you for the report.

In fact, this issue it's detected on other series and fixed, it's a matter of updating F4. For the solution it was the adding of an else condition when (nb_remaining_rx_data == huart->RxXferSize)

With regards.

KRASTM commented 2 weeks ago

ST Internal Reference: 189585