cancel
Showing results for 
Search instead for 
Did you mean: 

USART DMA always two times received.

DPaen.2
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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".

View solution in original post

2 REPLIES 2
TDK
Guru

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
Associate II

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;