Skip to main content
moon1003
Associate III
May 26, 2022
Question

I am doing UART communication with STM32H735G-DK. Without FreeRTOS, It works fine if you do it like this: HAL_UART_Transmit(&huart1, str, sizeof(str), 1000); However, there is no UART output in FreeRTOS.

  • May 26, 2022
  • 4 replies
  • 3537 views

..

4 replies

moon1003
moon1003Author
Associate III
May 26, 2022

The FreeRTOS environment is a project created by TouchGFX.

The setting of the UART part is the same regardless of FreeRTOS.

moon1003
moon1003Author
Associate III
May 26, 2022

Even in the FreeRTOS environment, the HAL_UART_Transmit function is called normally and the value is put in the huart->Instance->TDR part.

 while (huart->TxXferCount > 0U)

  {

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

   {

    return HAL_TIMEOUT;

   }

   if (pdata8bits == NULL)

   {

    huart->Instance->TDR = (uint16_t)(*pdata16bits & 0x01FFU);

    pdata16bits++;

   }

   else

   {

    huart->Instance->TDR = (uint8_t)(*pdata8bits & 0xFFU);

    pdata8bits++;

   }

   huart->TxXferCount--;

  }

Tesla DeLorean
Guru
May 26, 2022

Make sure pins, clocks and peripheral are correctly initialized. ​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
moon1003
moon1003Author
Associate III
May 26, 2022

The port assignment was different.

thank you.

alister
Senior III
May 26, 2022

Side comment...

HAL_UART_Transmit is blocking and the cycles it waits for the transmit to complete are totally wasted.

An RTOS app can use HAL_UART_Transmit_IT or HAL_UART_Transmit_DMA instead, and use those cycles for something else, and... that makes RTOS a game-changer.

Graduate II
June 11, 2024

Thank you. I'm trying to use the HAL_UART_Transmit_IT() and HAL_UART_Receive_IT(). Do you have any example or recommendation ?

alister
Senior III
June 11, 2024

@iPAS wrote:

Thank you. I'm trying to use the HAL_UART_Transmit_IT() and HAL_UART_Receive_IT(). Do you have any example or recommendation ?


Many hits for it on Google. Read their source code, experiment with sending, watch what happens using a debugger, a terminal and, if necessary and using short sends of known data, using a CRO, then experiment with receiving using loopback or a terminal.