2022-05-25 06:40 PM
2022-05-25 06:43 PM
The FreeRTOS environment is a project created by TouchGFX.
The setting of the UART part is the same regardless of FreeRTOS.
2022-05-25 06:45 PM
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--;
}
2022-05-25 07:49 PM
Make sure pins, clocks and peripheral are correctly initialized.
2022-05-25 08:14 PM
The port assignment was different.
thank you.
2022-05-25 10:54 PM
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.
2024-06-10 06:18 PM
Thank you. I'm trying to use the HAL_UART_Transmit_IT() and HAL_UART_Receive_IT(). Do you have any example or recommendation ?
2024-06-10 08:48 PM
@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.
2024-06-10 11:24 PM
Do you suggest that the rtos do not swich task while HAL calls wait in HAL_UART_Transmit or to that matter any hal calls? I was under the impression that once the scheduling is enabled, other task can function normally?
2024-06-11 05:58 PM
@Techn wrote:Do you suggest that the rtos do not swich task while HAL calls wait in HAL_UART_Transmit or to that matter any hal calls? I was under the impression that once the scheduling is enabled, other task can function normally?
An RTOS may switch which task is executing by many different ways. It's not limited to the task executing some RTOS function to yield itself, and obviously it couldn't execute such an RTOS function while it's executing HAL_UART_Transmit.
The HAL_UART_Transmit function is a blocking function. Its source code says so. Its source code shows you that it doesn't know anything about the RTOS, it starts the UART's transmit and then it loops polling the UART's transmit transmit status until either the transmit is completed or timed out. The HAL_UART_Transmit is not a sensible function to use if your code has anything else important to do.
Your code must transmit on a UART and you want to use an RTOS and HAL. My recommendation is