AnsweredAssumed Answered

HAL_UART_Receive() doesn't timeout

Question asked by Guo.Bryan.001 on Apr 26, 2017
Latest reply on Apr 26, 2017 by Clive One

Hi all,

 

I found my call HAL_UART_Receive() doesn't timeout.  Do you have any suggestion what I forget configure?

 

In CubeMX, I add uart2 and tim2 and I add my timer callback as this.

 

/* USER CODE BEGIN 4 */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
sprintf(aTxBuffer,"\r\nSTM32CubeMX rocks %d times \t", ++nbtime);
HAL_UART_Transmit(&huart2,(uint8_t *) aTxBuffer, strlen(aTxBuffer), 5000);
//printf("input:\r\n");
HAL_UART_Receive(&huart2,(uint8_t *) aRxBuffer, 10, 500);
HAL_UART_Transmit(&huart2,(uint8_t *) ack, 11, 5000);
}
/* USER CODE END 4 */

 

 

If I input 10 characters, the code works well.  However, if I don't input any thing,  HAL_UART_Receive() will not return. I believe it should return in 5000 ms. Do you have any idea about this?

 

PS: I'm using STM32L072. 

Outcomes