Skip to main content
Visitor II
November 30, 2023
Question

UART TIME OUT

  • November 30, 2023
  • 3 replies
  • 1704 views

Hello everyone 

I am trying to receive file form UART through Xmodem protocol I am getting file in debug mode but unable to get into run mode it showing  UART Rx busy basically hanging over these function 


while (!(HAL_UART_GetState(&huart4) == HAL_UART_STATE_READY) && wTimeout) {
wTimeout--;
}

if (HAL_UART_GetState(&huart4) == HAL_UART_STATE_READY)
break;
}

Can anyone suggest me for the what's wrong with the code  

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    November 30, 2023

    Hello @PESHWA 

    Could you specify the product being used, please?

     

    PESHWAAuthor
    Visitor II
    December 1, 2023

    yes STM32L4 MCU and with help of tera term as serial terminal as any idea why this happening 

     

    NOTE : I am using IAR workbench as IDE 

    Graduate II
    November 30, 2023

    The host isn't sending data?

    You've got some stuck error status like noise, framing, parity, overrun that you need to clear before reception works?

    PESHWAAuthor
    Visitor II
    December 1, 2023

    HI Host is sending char(C) as per showing on serial terminal 

    Graduate II
    November 30, 2023

    The timeout also isn't time bound it's iteration bound and this can change depending on execution speed and optimization. You need it to run in consistent time.

    PESHWAAuthor
    Visitor II
    December 1, 2023

    Hi

    I am doing in consistent time frame 

    /* USER CODE END UART4_Init 1 */
    huart4.Instance = UART4;
    huart4.Init.BaudRate = 19200;
    huart4.Init.WordLength = UART_WORDLENGTH_8B;
    huart4.Init.StopBits = UART_STOPBITS_1;
    huart4.Init.Parity = UART_PARITY_NONE;
    huart4.Init.Mode = UART_MODE_TX_RX;
    huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart4.Init.OverSampling = UART_OVERSAMPLING_16;
    huart4.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
    huart4.Init.ClockPrescaler = UART_PRESCALER_DIV1;
    huart4.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
    if (HAL_UART_Init(&huart4) != HAL_OK)
    {
    Error_Handler();
    }
    if (HAL_UARTEx_SetTxFifoThreshold(&huart4, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
    {
    Error_Handler();
    }
    if (HAL_UARTEx_SetRxFifoThreshold(&huart4, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
    {
    Error_Handler();
    }
    if (HAL_UARTEx_DisableFifoMode(&huart4) != HAL_OK)
    {
    Error_Handler();
    }

    here are my uart configuration and Iam using uart interrupt for communicate