Skip to main content
moon1003
Associate III
May 26, 2022 1:40 AM UTC
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.

..

This topic has been closed for replies.

9 replies

moon1003
moon1003Author
Associate III
May 26, 2022 1:43 AM UTC

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 1:45 AM UTC

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 2:49 AM UTC

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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
moon1003
moon1003Author
Associate III
May 26, 2022 3:14 AM UTC

The port assignment was different.

thank you.

alister
Senior III
May 26, 2022 5:54 AM UTC

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
Jun 11, 2024 1:18 AM UTC

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
Jun 11, 2024 3:48 AM UTC

@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.