2016-07-11 11:15 AM
We are using HAL_UART_Receive function as mentioned below in the code for testing:
while(__HAL_UART_GET_FLAG(&huart1,UART_FLAG_RXNE)== RESET){};
{
for (uint8_t i=0; i < 5 ; i++)
{
HAL_UART_Receive(&huart1,RData,RdSize1,Timeout_test1);
RxDataStr = RxData[i];
}
}
RData is defined as uint8_t RData[5];
When we send the data for example ''Test1''. I can see only 1st character from the data. I debugged through the code and it seems that Timeout is occurring and it is not going through the HAL_UART_Receive loop to receive the rest of the data. Please help!2016-07-11 05:07 PM
Perhaps it would be less confusing if you had some coherent naming, and provided enough code and defines for things to make sense?
What is RxData?The STM32 receives one character at a time, RXNE doesn't mean 5 characters are ready.RData is a pointer to RData[0..4], not RData[i]2017-04-26 09:52 PM
I think your code should be like this first. Otherwise, you will only change the value of RData[0].
while(__HAL_UART_GET_FLAG(&huart1,UART_FLAG_RXNE)== RESET){};
{
for (uint8_t i=0; i < 5 ; i++)
{
HAL_UART_Receive(&huart1,&RData[i], RdSize1,Timeout_test1);
RxDataStr = RxData[i];
}
}
BTW, I also meet the timeout issue. If I input a character before I call
HAL_UART_Receive(), it will return
timeout and it will always return timeout after that.