2026-02-22 8:38 AM
Hi, I'm have a trouble with UART Interrupt when using FreeRTOS.
I want to receive a string buffer send from Serial Terminal ( Hercules Software ) using UART interrupt mode. But when I send data, I just receive 2 character.
Ex: When I send "Resume", I just got echo back 2 line: "Rx_data:R","Rx_data:e".
Has anyone else encountered this problem? Please share a solution with me.
This is my call back function:
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
HAL_UART_Receive_IT(&huart1, &Rx_data, 1);
if(Rx_data == '\n')
{
Rx_buffer[Rx_index] = '\0';
if(strcmp((char*)Rx_buffer,"Resume") == 0)
{
xTaskResumeFromISR(AboveNormalHandle);
}
Rx_index = 0;
}
else
{
if(Rx_index < sizeof(Rx_buffer)-1)
{
printf("Rx_data: %c \n",Rx_data);
Rx_buffer[Rx_index++] = Rx_data;
}
}
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
Solved! Go to Solution.
2026-02-22 9:33 AM
Don't do blocking calls (printf) within an interrupt.
Store everything to a circular buffer and handle in the main thread when you receive the terminating "\n".
2026-02-22 9:33 AM
Don't do blocking calls (printf) within an interrupt.
Store everything to a circular buffer and handle in the main thread when you receive the terminating "\n".