首先要,请在MDK(keil)工程属性的“Target“-》”Code Generation“中勾选”UseMicroLIB
在程序中添加Printf
1,#include <stdio.h>
2,添加
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
USART_SendData(USART1, (uint8_t) ch);
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)
{}
return ch;
}
3