cancel
Showing results for 
Search instead for 
Did you mean: 

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

Metya
Associate II

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);
	}
}

2 REPLIES 2
TDK
Guru

> 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".

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
Up vote any posts that you find helpful, it shows what's working..