I am trying to run UART on STM32 MCU using HAL library for one of my application. I would like to receive packet of data which I am not able to do. Can you please guide me in this? I have provide details below.
I have created an application where I can transmit and receive data over UART port one by one. I am also able to receive packets in sets where I know the size of the data.
But in my case, I want to receive data packet of unknown length and read from receive buffer one by one which I am not able to do. When I send a packet of data using serial terminal, UART function only reads the first character and then ignore the remaining.
I have added the code segment for the reference below. The code compiles correctly and is working. It's only when I send a packet "Hello" from the terminal(real term), the code reads only 'H'. In my application the packet size varies, hence I can't mention fixed size in function HAL_UART_Receive_IT.
-Regards
Hrishikesh
****************************************************************************************************
int iRxFlag = 0;
int main(void)
{
char cData;
HAL_Init();
MX_GPIO_Init();
MX_UART4_Init();
while(1)
{
if(iRxFlag)
{
iRxFlag = 0;
HAL_UART_Transmit(&huart4, (uint8_t*)&cData, 1, 1);
}
HAL_UART_Receive_IT(&huart4, (uint8_t*)&cData, 1);
HAL_Delay(250);
}
return 0;
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
iRxFlag = 1;
}
****************************************************************************************************
