Skip to main content
Frogram
Associate II
August 24, 2021
Solved

two UART DMA with timer interrupt

Hi, all

I am trying to receive packet from uart3 and send them to uart2

but the results of my trials are:

  1. transmit occurs every main cpu clock
  2. transmit occur just once

which I thought was:

  1. receive packet from uart3 when packet arrived, independently
  2. transmit that packet once for every 65ms

My problem is "once" and "every 65ms"

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)	{
	HAL_DMA_Abort_IT(&huart2);
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)	{
	HAL_UART_Receive_DMA(&huart3, (uint8_t*)b, 2);
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
	HAL_UART_Transmit_DMA(&huart2, (uint8_t*)b, 2);
}
HAL_UART_Receive_DMA(&huart3, (uint8_t*)b, 2);

It's what I tried, "b" is uint8_t array

Thanks.

This topic has been closed for replies.
Imen.DBest answer
ST Technical Moderator
August 24, 2021

Hello @Frogram​ and welcome to the Community :)

Please take a look into the STM32 UART DMA RX/TX application note contains explanation with examples.

Hope this helps you!

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks

5 replies

Imen.DBest answer
ST Technical Moderator
August 24, 2021

Hello @Frogram​ and welcome to the Community :)

Please take a look into the STM32 UART DMA RX/TX application note contains explanation with examples.

Hope this helps you!

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Frogram
FrogramAuthor
Associate II
August 24, 2021

Thanks!

I will check them right now

Frogram
FrogramAuthor
Associate II
August 24, 2021

I have no idea how to apply this in my project... TT

TDK
August 24, 2021

You don't need to call HAL_DMA_Abort_IT at the end of a completed transfer.

The other calls should work. Consider simplifying the problem by removing the timers and implementing a fixed delay. Toggle a pin instead of using UART to verify timings. Monitor return value from HAL calls to ensure they succeed.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Frogram
FrogramAuthor
Associate II
August 25, 2021
/*inside of main*/
HAL_TIM_Base_Start_IT(&htim6);
HAL_UART_Receive_DMA(&huart2, (uint8_t *)b, 8);
 
/*outside of main*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
	if (htim == &htim6) {
		HAL_UART_Transmit_DMA(&huart3, (uint8_t *)b, 8);
	}
}

It worked! thanks all