Skip to main content
Associate III
November 19, 2023
Question

uart1_printf_debug

  • November 19, 2023
  • 1 reply
  • 792 views

hi i would like to use uart1_printf_debug debugging on a serial terminal but error message "undefine reference to "uart1_printf_debug" what file to include except stdio.h? 

This topic has been closed for replies.

1 reply

AScha.3
Super User
November 19, 2023

you need something like this in main.c :

 

/* USER CODE BEGIN 4 */

/**
 * @brief Retargets the C library printf function to the USART.
 * None
 * @retval None
 */
int __io_putchar(int ch)
{

 HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);

 return (ch);
}

 

then just use printf(...);

If you feel a post has answered your question, please click on " Best Answer ".