OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3770|回复: 1

为什么不能printf输出,急死我了!!!!!!

[复制链接]

6

主题

16

帖子

0

精华

初级会员

Rank: 2

积分
62
金钱
62
注册时间
2014-11-25
在线时间
0 小时
发表于 2014-12-23 23:20:51 | 显示全部楼层 |阅读模式
5金钱
#include "stm32f10x.h"
#include "stdio.h"

int SendChar (int ch);
int fputc(int ch, FILE *f);
int GetKey (void);
void USART1_Config(void);
void GPIO_Config(void);
/*----------------------------------------------------------------------------*/



int main(void)
{
SystemInit();
GPIO_Config();
USART1_Config();

printf(" --串口printf打印模板!--\r\n");

while(1)
{
printf(" --串口printf打印模板!--\r\n");
}
}



/* Implementation of putchar (also used by printf function to output data)    */
int SendChar (int ch)  {                /* Write character to Serial Port     */

  USART_SendData(USART1, (unsigned char) ch);
  while (!(USART1->SR & USART_FLAG_TXE));
  return (ch);
}


int GetKey (void)  {                    /* Read character from Serial Port    */

  while (!(USART1->SR & USART_FLAG_RXNE));
  return (USART_ReceiveData(USART1));
}



/*******************************************************************************
* Function Name : fputc
* Description   : Retargets the C library printf function to the USART.
* Input         : None
* Output         : None
* Return         : None
*******************************************************************************/
int fputc(int ch, FILE *f)
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the USART */
  USART_SendData(USART1, (u8) ch);

  /* Loop until the end of transmission */
  while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
  {
  }

  return ch;
}

最佳答案

查看完整内容[请看2#楼]

有样学样。 我们大把例程不去看,在这里瞎着急。
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2014-12-23 23:20:52 | 显示全部楼层
有样学样。
我们大把例程不去看,在这里瞎着急。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-27 15:57

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表