Skip to main content
Metya
Associate
August 14, 2020
Question

[STM32F072] Problem in use all 4 UARTs in same time

  • August 14, 2020
  • 2 replies
  • 678 views

I am creating a hub to connect several devices together. When I send a frame to one of the UARTs from an external device, I get an interrupt from each of the UARTs instead of just the one I sent to. what i am doing wrong?

I generated configuration in STM32CubeIDE.

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	if (huart->Instance == USART1)
	{
		HAL_UART_Receive_IT(&huart1, &rxBuffer[0], 1);
	}
	else if (huart->Instance == USART2)
	{
		HAL_UART_Receive_IT(&huart2, &rxBuffer[1], 1);
	}
	else if (huart->Instance == USART3)
	{
		HAL_UART_Receive_IT(&huart3, &rxBuffer[2], 1);
	}
	else if (huart->Instance == USART4)
	{
		HAL_UART_Receive_IT(&huart4, &rxBuffer[3], 1);
	}
}

This topic has been closed for replies.

2 replies

TDK
August 14, 2020

> I get an interrupt from each of the UARTs instead of just the one I sent to.

How do you know? Prove what you're saying is correct.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Guru
August 14, 2020

Pretty sure nobody is going to be able to replicate your observation from the code provided.

The callback can only enter with a single instance, you'll need to look upstream for the issue, I'd start with the IRQHandlers.

I'd also do a better job of buffering/signalling I had data.

I expect the HW to function as designed, try a simpler implementation, without HAL. Prove the HW works, then fix the SW you're using.

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