AnsweredAssumed Answered

USart not receiving data after awhile

Question asked by vu.andy on Jan 4, 2018
Latest reply on Jan 6, 2018 by Bogdan Golab

I am using STM32F051 device.  For some reason, after the host sending data for awhile, Rx stops receiving data.

If I use the debugger and stop the code, and try to send something back to the host, then the Rx begins receiving again.

So I am not sure why sending some data back to the host allows the Rx to receive data again.

 

Is there a flag I can check to see if there is any error? 

 

Here are the codes to initialize UART.

void MX_USART1_UART_Init(void)
{
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 9600;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  if (HAL_UART_Init(&huart1) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }
    
    UsartBuff[0] = 0;
    UsartBuff[1] = 0;
    L_UsartDataIdx = 0;
    
    InitUsartReceiveIT();
}

Outcomes