cancel
Showing results for 
Search instead for 
Did you mean: 

__HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)

DNguy.11
Associate II

I am using STM32F427ZIT6 with both USART1 and USART3. Both USART ports are DMA enable. I use STM32CubeMX version 6.2.1 to generate the code.

My problem is when USART3 is not transmitted, USART1 communication works as expected.

When USART3 is transmitted, USART1 data is corrupted. My question is

  __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx);

  __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart3_tx);

Would the same hdmatx cause my problems?

9 REPLIES 9

Presumably uartHandle would actually need to be USART/UART UNIQUE, it is an instance for carrying around related data.

And yes more generally you can't share DMA resources, there's a table in the Reference Manual, and you need to pick resources/options which don't conflict with each other.

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

It's not the same hdmatx. One is huart1.hdmatx and one is huart3.hdmatx. I can't see that being the problem.

#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)               \
                        do{                                                      \
                              (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
                              (__DMA_HANDLE__).Parent = (__HANDLE__);             \
                          } while(0U)

If data is sent (even if it is corrupted) it suggests the DMA part is working.

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

Thank you so much for your quick response. Would you fix in the next version STM32CubeMX generate code?

In HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) from attached code. Line 155 and 218 reference to hdmatx?

I would need to have both USART1 and USART3 working independently. Not just DMA

I understand that you are seeing issues but I do not believe the bug is in the code you have presented.
If you feel a post has answered your question, please click "Accept as Solution".

If I turn DMA off on USART3 and there is no problem on USART1. Would that tell me there is a code issue in HAL_UART_MspInit(). I will try to do that and let you know. Thanks

Ensure MX_DMA_Init is being called before the UART initialization functions.

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

Confirm. If I don't turn on debug trace on USART3, USART1 and DMA works