How to get UART data properly?
Hi, I'm using stm32f401RE.
I set UART functions by using CubeMX and I'm trying to get data from UART and distinguish them.
Here is the code.
uint8_t RxBuffer[8];
HAL_UART_Receive_IT(&huart2, (uint8_t*)RxBuffer,sizeof(RxBuffer)); // Writed in while loop
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART2)
{
if(RxBuffer[0]=='h')
{
check=1;
}
}
}And this is the problem. When I set 'uint8_t Rxbuffer[1]' and send 'h' then the above conditional statement react. But when I set 'uint8_t Rxbuffer[8]' then I have to send 'hhhhhhhh' to get reaction. It means I have to send 'h' 8 times. It doesn't work when I send '1234567h' or 'h1234567'.
I can't find why this happens. I'm looking for some helps. Thanks