Skip to main content
DPaen.2
Associate
December 23, 2021
Solved

USART DMA always two times received.

I'm using STM32L476 MCU.

I config DMA Setting for USART.

0693W00000HpcwSQAR.png 

And I use HAL_UART_Receive_DMA in main.c

If I received data, test_count always increase two.

void DMA1_Channel6_IRQHandler(void)

{

 /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */

  test_count ++;

 /* USER CODE END DMA1_Channel6_IRQn 0 */

 HAL_DMA_IRQHandler(&hdma_usart2_rx);

 /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */

 /* USER CODE END DMA1_Channel6_IRQn 1 */

}

Is there anyone who can help?

This topic has been closed for replies.
TDK
TDKBest answer
December 23, 2021

It increases once for the HT interrupt and one for the TC interrupt. Working as intended.

If you want to do something at the end of the transfer, implement and use HAL_UART_TxCpltCallback.

"If you feel a post has answered your question, please click ""Accept as Solution""."

2 replies

TDK
TDKBest answer
December 23, 2021

It increases once for the HT interrupt and one for the TC interrupt. Working as intended.

If you want to do something at the end of the transfer, implement and use HAL_UART_TxCpltCallback.

"If you feel a post has answered your question, please click ""Accept as Solution""."
DPaen.2
DPaen.2Author
Associate
December 23, 2021

Thank you.

I don't want to use callback function.

So I changed code.

  /* Set the UART DMA transfer complete callback */

  huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt;

  /* Set the UART DMA Half transfer complete callback */

  //huart->hdmarx->XferHalfCpltCallback = UART_DMARxHalfCplt;