Tranceiving & Receiving Data with UART on STM32H735G-DK
Dear all,
I've been wrestling with a communication glitch that's been causing me some serious headaches. Here's the lowdown: I've got this control board hooked up to a pump, and I've been trying to send commands to it via USART1 on my own STM32H735G-DK. The problem? It seems my board's only sending half the message, which is a major problem because those messages serve as commands for the pump.
After some debugging, I've narrowed down the issue to my UART interrupt. I thought I'd solved the issue by disabling the interrupt, sending the data, and then re-enabling it once the message was fully sent. But alas, that meant losing crucial data coming back from the pump, which is just as vital as sending commands. So it's a classic catch-22 situation: sacrifice the first half of my Rx message to send data, or lose the second half of my Tx message to receive data. I've verified this by scrutinizing the signal with my Oscilloscope's Decoder.
My messages are short, typically 1-40 characters, but their size can be unpredictable.
Any ideas on how to tackle this problem? I'm more than happy to share my code if it'll shed some light. Below are the relevant snippets:
__disable_irq();
if (pumpNo == 1)
{
HAL_UART_Transmit(&huart1, pumpCommand, newlineIndex+1, HAL_MAX_DELAY);
}
else
{
printf("ERROR: PUMP NOT FOUND");
UartRxData1[0] = '5';
temp1[0] = '\n';
}
__enable_irq();
HAL_UART_Receive_IT(&huart1, temp1, 1);
And the interrupt callback:
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
memcpy (UartRxData1+uartIndx1, temp1, 1);
if (++uartIndx1 >= 64)
{
memset(UartRxData1, 0, sizeof UartRxData1);
uartIndx1 = 0;
}
HAL_UART_Receive_IT(&huart1, temp1, 1);
}
// USART1 Interrupt
HAL_UART_Receive_IT(&huart1, temp1, 1);
Any advice or help would be greatly appreciated!
