cancel
Showing results for 
Search instead for 
Did you mean: 

UART DMA not transmitting data properly

fa31
Associate III

Hi,

I am working on a project and having the following problem:
My UART DMA is not working. I am transmitting a string, that should be visible in the terminal but it is not. The TX complete callback function is being triggered, so it looks like it works but there is nothing in the terminal.

Previously, I was using UART without DMA and things were working fine. It confirms that the hardware connections and the VCP connections are correctly set up.

 

What I have done so far:

- I enabled UART2, tested UART (without DMA). It worked well.

- I enabled DMA which gave me:

fa31_0-1752840534623.png

 

- Then I set up GPDMA1 for huart2_TX and huart2_RX. My TX configs are:

Screenshot 2025-07-18 140925.png

 

My main function:

int main(void)
{
  HAL_Init();
  SystemClock_Config();

  MX_GPIO_Init();
  MX_GPDMA1_Init();
  MX_ICACHE_Init();
  MX_USART2_UART_Init();


  /* Infinite loop */
  while (1)
  {
	  static uint32_t counter = 0;
	  sprintf((char *)pTxBuff, "Count: %lu\r\n", counter++);
	  if (huart2.gState == HAL_UART_STATE_READY) {
	      HAL_UART_Transmit_DMA(&huart2, pTxBuff, strlen((char *)pTxBuff));
	  }
	  HAL_Delay(1000);
  }
}

 

Does anyone have insights into why UART2 DMA transmission is not functioning correctly and why no output is appearing on the terminal, despite the transmission complete callback being triggered?

Thanks!

 

4 REPLIES 4
mƎALLEm
ST Employee

Hello,

What product are you using and what board are you using?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Andrew Neil
Super User

@fa31 wrote:

Previously, I was using UART without DMA and things were working fine.


If you go back to that, does it still work?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
fa31
Associate III

I am using:

CubeMX: to generate the code        Version: 6.14.1

CubeIDE: to debug the code            Version: 1.18.1

Board: Nucleo WBA65RI

What versions?

How to write your question to maximize your chances to find a solution

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.