Skip to main content
Explorer
February 22, 2026
Solved

Receive A Buffer From UART in FreeRTOS

  • February 22, 2026
  • 1 reply
  • 127 views

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

 

Best answer by TDK

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

1 reply

TDK
TDKBest answer
Super User
February 22, 2026

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

"If you feel a post has answered your question, please click ""Accept as Solution""."