Skip to main content
Visitor II
February 24, 2023
Solved

Question about the Azure RTOS ThreadX Semaphore example

  • February 24, 2023
  • 2 replies
  • 1685 views

Hello,

in the Semaphore example(https://community.st.com/s/article/how-does-the-threadx-semaphore-work) there is this step:

Open Core\Src \main.c – you can copy and paste the code below, but please notice the" USER CODE BEGIN", to properly place the code snippet:

/* Private user code ---------------------------------------------------------*/
 
/* USER CODE BEGIN 0 */
 
#define USE_UART_PRINT
 
void __io_putchar(char ch) {
 
#ifdef USE_UART_PRINT
 
 // Code to write character 'ch' on the UART
 
 HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 10);
 
#else
 
 ITM_SendChar(ch);
 
#endif
 
}
 
/* USER CODE END 0 */

The question I have is why is this step and piece of code needed? I understand the previous steps and the code that I need to add in the \app_threadx.c file. But this part I am not sure and it is not explained in the guide.

Can anyone please tell why this part is needed?

Thank you

    This topic has been closed for replies.
    Best answer by Haithem Rahmani

    Hi,

    this is needed to redirect the printf() output to the serial port.

    regards

    Haithem

    2 replies

    ST Employee
    February 25, 2023

    Hi,

    this is needed to redirect the printf() output to the serial port.

    regards

    Haithem

    MStew.1Author
    Visitor II
    February 26, 2023

    solved

    MStew.1Author
    Visitor II
    February 25, 2023

    Ah ok thank you!