在stm32 单片机程序中使用printf()进行串口调试
来源:互联网 发布:8787端口是干嘛的 编辑:程序博客网 时间:2024/05/07 18:28
在单片机使用printf()函数进行程序调试很方便,官方给的串口输出函数功能比较单一,又满足不了要求。
修改方法如下:
1、在.c文件中包含如下代码:
#ifdef __GNUC__/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar() */#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)#else#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)#endif /* __GNUC__ */PUTCHAR_PROTOTYPE{ /* Place your implementation of fputc here */ USART_SendData(USART1, (uint8_t) ch); /* Loop until the end of transmission */ while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) {} return ch;}2、然后包含头文件。
#include "stdio.h"
如此,便可使用其进行格式化输出。
0 0
- 在stm32 单片机程序中使用printf()进行串口调试
- 51单片机在Keil中使用printf进行串口输出
- 在STM32使用串口printf
- STM32在IAR和MDK中使用printf进行串口打印的实现方法
- 在STM32中使用printf发送字符串到串口
- 怎样在TI stellaris lm3sxxx 程序中使用C语言printf()函数进行串口输出
- STM32 DAC调试及在mdk中使用printf
- STM32中使用printf打印串口数据
- KEIL下STM32如何使用printf函数进行串口输出
- STM32高级开发(12)-在GCC中使用printf打印串口数据
- 在MDK中使用printf及串口
- stm32 中printf使用
- STM32单片机学习(7) 串口通信printf重定向
- 使用CoIDE调试STM32单片机
- 使用CoIDE调试STM32单片机
- STM32中printf重定向到串口
- STM32中printf重定向到串口
- STM32中printf重定向到串口
- STM32CUBE学习——2
- hdu 1272 小希的迷宫 并查集
- quick-cocos2d-x 学习系列之十一mvc例子
- 优于KMean聚类的 快速聚类算法(Clustering by fast search and find of density peaks_Science2014)
- 二维数组指针
- 在stm32 单片机程序中使用printf()进行串口调试
- 软件工程的回顾总结
- Makefile管理多个模块的项目
- 欢迎使用CSDN-markdown编辑器
- 软件开发文档范例
- strcmp函数实现
- Windows下搭建基于ssh的git服务器
- 寒假集训--Video Game Troubles
- 自定义控件---继承ViewGroup类方式(循序渐进之第3步效果----图片左右拖动+RadioGroup切换效果)