编程浪子的博客

碌碌无为终为过

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

首先,要包含头文件"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;
}

Technorati 标记: MDK,STM32,printf
posted on 2013-05-20 13:16  编程浪子_  阅读(7028)  评论(0编辑  收藏  举报