让单片机直接支持printf函数
来源:互联网 发布:世界云计算公司排名 编辑:程序博客网 时间:2024/06/04 23:04
在使用单片机的时候经常需要使用到UART输出一些调试信息。通常情况下是自己写一些类似UART_SendChar();或者UART_SendString();之类的函数。但是这种有时候对于输出的格式支持并不是很好。而且移植起来也不方便。
其实只要重定向printf函数就可以了。在KEIL里面不需要勾选 use Micro LIB
#pragma import(__use_no_semihosting) //
struct __FILE
{
int handle;
/* Whatever you require here. If the only file you are using is */
/* standard output using printf() for debugging, no file handling */
/* is required. */
};
/* FILE is typedef¡¯ d in stdio.h. */
FILE __stdout;
_sys_exit(int x)
{
x = x;
}
int fputc(int ch, FILE *f)
{
while((USART1->SR&0X40)==0);//这里是和单片机有关的串口输出 不同单片机写法不一样
USART1->DR = (u8) ch;
return ch;
}
阅读全文
0 0
- 让单片机直接支持printf函数
- 关于单片机printf函数
- 单片机printf函数重定向
- 单片机系统重写printf函数
- pic单片机使用printf函数
- printf 函数支持
- Eclipse支持printf()函数吗?
- 单片机 printf函数的查看使用
- 单片机中printf函数的重映射
- 51单片机实现scanf和printf函数
- C51单片机自实现printf函数
- 51单片机实现scanf和printf函数
- 51单片机自己动手写一个printf函数
- 让MDK支持printf(基于stm32)
- 让MDK支持printf(基于stm32)
- 让MDK支持printf(基于stm32)
- 如何在单片机上使用printf函数(printf)(avr)(stm)(lpc)(单片机)
- 单片机不支持printf函数,实现几个常用串口打印函数
- 移动端UI设计750揭秘
- MySQL调优三步曲(慢查询、explain profile)
- 嵌入式软件测试的十大方法
- Linux常用shell命令
- 得到听书笔记
- 让单片机直接支持printf函数
- 版本控制-Git
- Android的生命周期和启动模式
- 关于DNN(CNN)在图像分类中的一些学习资料
- 线段树简单实现
- How to set default values for IBInspectable in Objective-C?
- 关于Jsp中的几个域对象的学习总结
- 【JavaSE笔记】Java常见细节性问题(一)
- HTML笔记(HTML元素-表单)