AnsweredAssumed Answered

how to use "printf"?

Question asked by Kim.Min_Kyoung on Feb 9, 2017
Latest reply on Jan 27, 2018 by marinoni.enrico.003

I'm using examples of project  "UART_Printf". 

But I can't use printf. 

I set uart1. and I checked that uart1 tx/rx works. 

I added below code to my source. 

 

 

#include "stdio.h"

 

#ifdef __GNUC__
/* With GCC/RAISONANCE, 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__ */

 

PUTCHAR_PROTOTYPE
{
/* Place your implementation of fputc here */
/* e.g. write a character to the USART1 and Loop until the end of transmission */
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);

return ch;
}

Outcomes