2020-08-14 12:14 AM
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);
}
}
2020-08-14 06:28 AM
> 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.
2020-08-14 09:47 AM
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.