您的位置 首页 电路

IAR瑞萨单片机开发参加printf调试函数

IAR开发环境,没有printf函数,自己百度加入了一个(http://www.cnblogs.com/codecamel/p/4686437.html),但是还是有一些问题,特别是打印…

IAR开发环境,没有printf函数,自己百度参加了一个(http://www.cnblogs.com/codecamel/p/4686437.html),可是仍是有一些问题,特别是打印多个变量时,只能够打印字符串时比较稳定,原因是因为va_arg()给了过错的返回值,故只能找寻其他的方法,今日测试了一下,新的方法过程如下

1.要害之处,不然会呈现PUTCHAR函数未定义现象。

右键点击工程挑选option->General Option->ibrary configuration中library改为full,且General Option->library option->Printf formatter选项中挑选full2

2. main.c中参加,其间运用的是串口1,留意假如提示FILE未定义,请在头文件最顶层增加#include

1 /* Privatefunction prototypes --*/2 3 #ifdef __GNUC__4 /* With GCC/RAISONANCE, small printf(option LD Linker->Libraries->Small printf5   set to Yes) calls __io_putchar() */6 #define PUTCHAR_PROTOTYPE int__io_putchar(int ch)7 #else8 #define PUTCHAR_PROTOTYPE int fputc(int ch,FILE *f)9 #endif /* __GNUC__ */10 11 /**12   *@brief  Retargets the C library printffunction to the USART.13   *@param  None14   *@retval None15   */16 PUTCHAR_PROTOTYPE17 {18   /*Place your implementation of fputc here */19   /*e.g. write a character to the USART */20  USART_SendData(EVAL_COM1, (uint8_t) ch);21   /*Loop until the end of transmission */22  while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET);23  return ch;24 }

printf函数打印字符串,遇到\0时才完毕。

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/dianlu/263724.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部