cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743 DMA not working

BPark.5
Associate II

In the program that transmits the value received from uart4 to uart5, I want to move the value received from uart5 to another buffer, but I move it to HardFault_Handler.

what is the reason?

And please check if the method of receiving data using the dma I implemented is the correct program.

 if((RX_BUFFER4_SIZE) != __HAL_DMA_GET_COUNTER(huart4.hdmarx) ){

   SCB_InvalidateDCache_by_Addr((uint32_t*)RX_BUFFER4, RX_BUFFER4_SIZE);    

   HAL_UART_Transmit(&huart5,RX_BUFFER4,RX_BUFFER4_SIZE-__HAL_DMA_GET_COUNTER(huart4.hdmarx),0xFFFFFFFF);  

    

   __HAL_DMA_DISABLE(huart4.hdmarx); 

   __HAL_DMA_SET_COUNTER(huart4.hdmarx,RX_BUFFER4_SIZE);

   __HAL_DMA_ENABLE(huart4.hdmarx);

   memset(RX_BUFFER4,0x00,sizeof(RX_BUFFER4));  

  }

  if((RX_BUFFER5_SIZE) != __HAL_DMA_GET_COUNTER(huart5.hdmarx) ){

    SCB_InvalidateDCache_by_Addr((uint32_t*)RX_BUFFER5, RX_BUFFER5_SIZE);      

   HAL_UART_Transmit(&huart4,RX_BUFFER5,RX_BUFFER5_SIZE-__HAL_DMA_GET_COUNTER(huart5.hdmarx),0xFF);

   memcpy(RX_BUFFER_WAV,RX_BUFFER5,4096-bytesRx);

   __HAL_DMA_DISABLE(huart5.hdmarx); 

   __HAL_DMA_SET_COUNTER(huart5.hdmarx,RX_BUFFER5_SIZE);

   __HAL_DMA_ENABLE(huart5.hdmarx);

   memset(RX_BUFFER5,0x00,sizeof(RX_BUFFER5));

  }

5 REPLIES 5

I don't understand the rational for the logic.

The buffers need to be properly aligned so the invalidation works properly.

The HAL_UART_Transmit()s will block.

You should be able to unpack the Hard Fault to understand, or surmise, the reason for it. You should be able to identify what the MCU doesn't like.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

What do you mean by sorting buffers?

please tell me specifically

TDK
Guru

Doesn't seem like you're using the right calls. If you want to use DMA, then HAL_UART_Transmit_DMA/HAL_UART_Receive_DMA should be used.

Also possibly this:

https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices

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

yes thank you so much for your help

I changed the setting value by referring to the data you sent

However, when data is sent to uart5, it says that it receives a value in the receive buffer and then does not receive it.

Changed HAL_UART_Transmit -> HAL_UART_Transmit_DMA.

> it says that it receives a value in the receive buffer and then does not receive it.
No idea what this means.
There are examples for UART DMA in the Cube repository you should get working.
If you feel a post has answered your question, please click "Accept as Solution".