cancel
Showing results for 
Search instead for 
Did you mean: 

Bug with STM32F7 HAL UART Tx DMA

alexpabouct9
Associate II
Posted on March 21, 2016 at 20:10

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 callingHAL_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 toHAL_UART_STATE_READY. Can you please confirm if this is indeed a bug? Thanks, Alex #bug #stm32f7-hal-uart
5 REPLIES 5
Walid FTITI_O
Senior II
Posted on March 22, 2016 at 12:15

Hi pabouctsidis.alex,

Thanks for the feedback. I will check it internally and come back to you.

-Hannibal-

Walid FTITI_O
Senior II
Posted on March 23, 2016 at 11:14

Hi pabouctsidis.alex,

It is not a bug.

You should ensure that you have puted the USARTx_ IRQHandler inside ''stm32f7xx_it.c'', in addition to USARTx-DMA_TX and USARTx-DMA_RX IRQHandlers .

The set of the ready flag is managed inside HAL_UART_IRQHandler() by the UART_EndTransmit_IT().

-Hannibal-

alexpabouct9
Associate II
Posted on March 24, 2016 at 10:00

Thanks for checking.

In that case, the stm32cube did not generate the proper code. the USART init doesnt configure the nvic for usart interrupts, and there is no USART interrupt handler in stm32fxx_it.c

Furthermore, calling the usart interrupt after the transmission complete dma interrupt makes very little sense, and seems like needless overhead.
Walid FTITI_O
Senior II
Posted on March 24, 2016 at 15:20

Hi bouctsidis.alex,

I Think you mean STM32CubeMX that you have used to generate. Please tru to share your .ioc file and mention which version you have used .

-Hannibal-

Dmitry Bravikov
Associate II
Posted on August 05, 2016 at 17:24

Hello,

I have the same problem.

It seems to me, that USARTx_ IRQHandler will called for every byte. I'm right?