Skip to main content
KiptonM
Senior III
February 9, 2021
Solved

How do you start DMA with interrupts? huart4.Instance->CR3 |= USART_CR3_DMAT; HAL_DMA_Start_IT(&hdma_uart4_tx,(uint32_t)msg, (uint32_t)&huart4.Instance->TDR,len); Works the first time, but if you change msg and len it repeats first case.

  • February 9, 2021
  • 3 replies
  • 1068 views

I need the callback, to clear the cb4.DMA_Active flag and update a pointer when it finishes.

I cannot step through it because it starts sending data over and over as I step through it and does not call the callback.

First time msg points to "1234567890\r\n" len = strlen(msg)

Second time msg points to "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n", len= strlen(mssg)

Second time it sends "1234567890\r\n" again.

static void dma_debug_write(char *msg, size_t len)

{

   // this is the real code I want to run.

   cb4.DMA_Active = 1;

   huart4.Instance->CR3 |= USART_CR3_DMAT;

   HAL_DMA_Start_IT(&hdma_uart4_tx,

               (uint32_t)msg,

                (uint32_t)&huart4.

               Instance->TDR,

               len);

}

What am I missing?

This topic has been closed for replies.
Best answer by Pavel A.

You are missing the famous set of examples for UART with DMA by Tilen Majerle.

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

Enjoy!

-- pa

3 replies

KiptonM
KiptonMAuthor
Senior III
February 9, 2021
Pavel A.
Pavel A.Best answer
Super User
February 9, 2021

You are missing the famous set of examples for UART with DMA by Tilen Majerle.

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

Enjoy!

-- pa

KiptonM
KiptonMAuthor
Senior III
February 10, 2021

Thanks. That did not pop up on the search engine.

I will look at it in the morning.