2026-03-26 2:44 AM - last edited on 2026-03-26 2:58 AM by Peter BENSCH
Hi, I am using an STM32F767ZI to communicate with a Dacai HMI display over UART7 at 9600 baud. Sending data from the STM32 to the HMI works perfectly, but receiving data from the HMI is unreliable. The same HMI works fine when communicating with other MCUs—both TX and RX work reliably.
When I touch:
HMI tool shows this frame:
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
if (huart->Instance == UART7) {
HAL_GPIO_TogglePin(GPIOB, LD1_Pin); // debug
uint8_t b = rx_byte;
if (frameIndex == 0 && b != 0xEE) {
HAL_UART_Receive_IT(&huart7, &rx_byte, 1);
return;
}
if (frameIndex == 1 && b != 0xB1) {
clearFrameBuffer();
if (b == 0xEE) frame[frameIndex++] = b;
HAL_UART_Receive_IT(&huart7, &rx_byte, 1);
return;
}
if (frameIndex == 2 && b != 0x11) {
clearFrameBuffer();
HAL_UART_Receive_IT(&huart7, &rx_byte, 1);
return;
}
frame[frameIndex++] = b;
if (frameIndex >= 15) {
if (frame[frameIndex - 4] == 0xFF && frame[frameIndex - 3] == 0xFC &&
frame[frameIndex - 2] == 0xFF && frame[frameIndex - 1] == 0xFF) {
frameReady = 1;
clearFrameBuffer();
}
}
HAL_UART_Receive_IT(&huart7, &rx_byte, 1);
}
}
I suspect this issue might be related to timing, buffer handling, or UART configuration, but I am not sure what is causing the missed data.
Any help or debugging suggestions would be greatly appreciated!
2026-03-26 3:04 AM
Welcome @Dhinakaran, to the community!
Please first verify the low‑level UART side:
These points usually fix rarely called HAL_UART_RxCpltCallback problems on STM32F7 when TX works but RX is unreliable.
Hope that helps?
Regards
/Peter