2021-11-12 08:35 AM
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?
2021-11-12 08:39 AM
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.
2021-11-12 08:41 AM
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.
2021-11-12 08:41 AM
Thank you so much for your quick response. Would you fix in the next version STM32CubeMX generate code?
2021-11-12 08:44 AM
In HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) from attached code. Line 155 and 218 reference to hdmatx?
2021-11-12 08:48 AM
I would need to have both USART1 and USART3 working independently. Not just DMA
2021-11-12 08:50 AM
2021-11-12 08:56 AM
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
2021-11-12 09:05 AM
Ensure MX_DMA_Init is being called before the UART initialization functions.
2021-11-12 09:30 AM
Confirm. If I don't turn on debug trace on USART3, USART1 and DMA works