您的位置:首页 > 其它

STM32 MDK工程中使用printf

2013-12-22 22:06 302 查看
首先,要包含头文件"stdio.h"

第二:printf()函数使用了int fputc(int ch,FILE *f)完成其功能。

要使用printf,就需要重写这个函数。

第三,在工程选项的Target里边勾选USE MicroLIB项。

fputc示例如下:

int fputc(int ch,FILE *f)

{

/* Place your implementation of fputc here */

/* e.g. write a character to the USART */

USART_SendData(USART1, (uint8_t) ch);

/* Loop until the end of transmission */

while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)

{}

return ch;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: