cancel
Showing results for 
Search instead for 
Did you mean: 

Transmit UART with DMA in IDLE interrupt of Receive DMA

DBrau.2
Associate III

Hello.

Could anyone explain me why when I try to transmit data by UART using DMA in IDLE interrupt  function from receive DMA on the same UART working in circular mode, once in several attempts my reception lost some data? TX and RX use different channels of DMA.

When I change Trasmit_DMA to casual Transmit in work even though the interrupt handling takes more time. 

12 REPLIES 12

At this point, you are dealing with details of your own system design, and I don't think I can help with that.

JW

 

DBrau.2
Associate III

I can add that I have replaced DMA channel with TX of another UART and not it seems to work correctly. RX and TX on one UART use not only different DMA channels but different DMA.

Karl Yamashita
Lead III

Don't write your code in HAL_UART_IRQHandler and leave it as is. I've seen other programmers do this and their code don't work correctly, which i confirmed. 

void UART5_IRQHandler(void)
{
  HAL_UART_IRQHandler(&huart5);
}

Instead do it the HAL_UARTEx_RxEventCallback callback. After some testing, i found that writing code in the callback instead, fixed the other programmers issue. See if this works for you?

You might want to pass Size to your EngineAT_execute to help you copy the correct amount of bytes to your buffer?

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
	if(huart == &huart5)
	{
		EngineAT_execute();
	}
}

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.