cancel
Showing results for 
Search instead for 
Did you mean: 

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.

KiptonM
Lead

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

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

View solution in original post

3 REPLIES 3
Pavel A.
Evangelist III

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
Lead

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

I will look at it in the morning.