cancel
Showing results for 
Search instead for 
Did you mean: 

two UART DMA with timer interrupt

Frogram
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

5 REPLIES 5
Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Frogram
Associate II

Thanks!

I will check them right now

Frogram
Associate II

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

TDK
Guru

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
Associate II
/*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