AnsweredAssumed Answered

BUG report: HAL STM32F1xx UART DMA never call TX complete call back

Question asked by code_crasher on Jun 22, 2016
Latest reply on Jun 23, 2016 by code_crasher
I found this with the latest HAL come with the cubemx 15.1
STM32F1 1.4.0

UART_DMATransmitCplt never call 
HAL_UART_TxCpltCallback, it also did not change the
uart->State cause the following uart transmit return with error
as busy.

It does not make sense that only circular mode will receive
DMA complete callback.

I use this patch to fix it.

diff --git a/cubef1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c b/cubef1/Drivers/STM32F1xx_HAL_Dr
iver/Src/stm32f1xx_hal_uart.c
index 600d936..9ab9a6e 100644
--- a/cubef1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c
+++ b/cubef1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c
@@ -1563,12 +1563,20 @@ static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma)
 
     /* Enable the UART Transmit Complete Interrupt */    
     __HAL_UART_ENABLE_IT(huart, UART_IT_TC);
+^M
+    /* Check if a transmit process is ongoing or not */^M
+    if(huart->State == HAL_UART_STATE_BUSY_TX_RX) ^M
+    {^M
+      huart->State = HAL_UART_STATE_BUSY_RX;^M
+    }^M
+    else^M
+    {^M
+      huart->State = HAL_UART_STATE_READY;^M
+    }^M
+^M
   }
   /* DMA Circular mode */
-  else
-  {
-    HAL_UART_TxCpltCallback(huart);
-  }
+  HAL_UART_TxCpltCallback(huart);^M
 }
 
 /**

Outcomes