How to get printf example working in another project
Hi,
I am working with the Nucleo-F401RE board and I am trying to implement the printf function to work with UART2. I can load and run the example project, but implementing the same code does not work in a separate project.
I have had zero luck getting this work after having read and implementing everything that I can find.
I have the following code in the main function taken from the example.
I am missing something crucial here and could use some insight.
Thanks,
D
/* USER CODE END PFP */
#ifdef __GNUC__
/* With GCC, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/* USER CODE BEGIN 0 */
PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */
HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}