AnsweredAssumed Answered

Bug with STM32F7 HAL UART Tx DMA

Question asked by Pabouctsidis.Alex on Mar 21, 2016
Latest reply on Aug 5, 2016 by Dmitry Bravikov
Hello,

I'm currently running on the STM32F746VG, and used CubeMX to generate the configuration code for a simple USART Tx Output using the DMA.

When calling HAL_UART_Transmit_DMA(..) it would transmit the data correctly for the first time (was confirmed with an oscilloscope) and then stop working.

In order to make it work i had to add a line to stm32f7xx_hal_uart.c line 1272: 

static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma)    
{
  UART_HandleTypeDef* huart = ( UART_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
   
  /* DMA Normal mode*/
  if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0)
  {
    huart->TxXferCount = 0;
 
    /* Disable the DMA transfer for transmit request by setting the DMAT bit
       in the UART CR3 register */
    huart->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DMAT);
 
    /* Enable the UART Transmit Complete Interrupt */
    __HAL_UART_ENABLE_IT(huart, UART_IT_TC);
 
    huart->State= HAL_UART_STATE_READY; // BUG CORRECTION
  }
  /* DMA Circular mode */
  else
  {
    HAL_UART_TxCpltCallback(huart);
  }
}

The callback was not resting the State flag to HAL_UART_STATE_READY.

Can you please confirm if this is indeed a bug?

Thanks,
Alex

Outcomes