1.关键之处,否则会出现PUTCHAR函数未定义现象。
右键点击工程选择option-> General Option->ibrary configuration中library改为full,且 General Option->library option->Printf formatter选项中选择full2
2. main.c中加入,其中使用的是串口1
/* ---------------------------Privatefunction prototypes -----------------------------------------------*/
#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__ */
和
/**
*@brief Retargets the C library printffunction to the USART.
*@param None
*@retval None
*/
PUTCHAR_PROTOTYPE
{
/*Place your implementation of fputc here */
/*e.g. write