2016-06-22 05:34 AM
I found this with the latest HAL come with the cubemx 15.1
STM32F1 1.4.0UART_DMATransmitCplt never call HAL_UART_TxCpltCallback, it also did not change theuart->State cause the following uart transmit return with erroras busy.It does not make sense that only circular mode will receiveDMA 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_Driver/Src/stm32f1xx_hal_uart.cindex 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 } /**2016-06-23 01:56 AM
Hi
This is not a bug, adding the USARTx_ IRQHandler inside the stm32f1xx_it.c file should resolve this issue:void USARTx_IRQHandler(void){ HAL_UART_IRQHandler(&UartHandle);}I suggest you refer to USART example using DMA under this path, it may be helpful: STM32Cube_FW_F1_V1.4.0\Projects\STM32VL-Discovery\Examples\UART\UART_TwoBoards_ComDMAFor more details , you can refer to the in (19.3.13 Continuous communication using DMA) paragraph.Regards2016-06-23 09:25 AM
Thanks. That seems work when I enable UART interrupt in CubeMX.
However, it means that I can't not use UART DMA mode without enableUART interrupt handler. It is a CubeMX bug then.Because I generated the code from CubeMX. CubeMX automaticallyenable DMA interrupt if I select DMA. Base on your feed back,the HAL layer will need UART interrupt handler to make the DMA work.The correct behavior for CubeMX should automatically enable UARTinterrupt as well.Does that make sense?