南兴 mfb-60c说明书:Keil-STM32程序(使用库)中添加printf函数

来源:百度文库 编辑:偶看新闻 时间:2024/04/26 13:12:21

Keil-STM32程序(使用库)中添加printf函数

2011-01-26 00:01:33|  分类: STM32 |  标签: |字号大中小 订阅

在串口能正常运行的前提下添加如下代码

头文件

#include "stdio.h"

声明

int fputc(int ch, FILE *f);

函数

int fputc(int ch, FILE *f)
{

USART_SendData(USART1, (uint8_t) ch);

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

return ch;
}

 

这样就应该可以使用printf输出字符串到电脑上了

还是不行的话查看一下

Target——Code Generation——选中Use MicroLIB