cancel
Showing results for 
Search instead for 
Did you mean: 

Issue using HAL UART Transmit

Posted on November 12, 2017 at 09:25

Hello

I am having issues with the following HAL function when trying to transmit data using HAL library:

if(UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)

It always return HAL_TIMEOUT.

I am setting serial port with:

/* USART3 init function */

static void MX_USART3_UART_Init(void)

{

  huart3.Instance = USART3;

  huart3.Init.BaudRate = 115200;

  huart3.Init.WordLength = UART_WORDLENGTH_8B;

  huart3.Init.StopBits = UART_STOPBITS_1;

  huart3.Init.Parity = UART_PARITY_NONE;

  huart3.Init.Mode = UART_MODE_TX_RX;

  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;

  huart3.Init.OverSampling = UART_OVERSAMPLING_16;

  if (HAL_UART_Init(&huart3) != HAL_OK)

  {

    _Error_Handler(__FILE__, __LINE__);

  }

}

and then transmitting data with:

      if(HAL_UART_Transmit(&huart3, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)

          {

            Error_Handler();

          }

#uart
2 REPLIES 2
S.Ma
Principal
Posted on November 12, 2017 at 13:31

Make sure the RCC configuration (clock enable) for the UART and the related GPIO port are enabled.

Make sure the GPIO AF (Alternate Functions) are properly setup

William chang
Associate III
Posted on March 08, 2018 at 04:31

Do you generate by CUBEMX, please post your project files too