当前位置:网站首页>MDK Keil/ARM printf 用法说明
MDK Keil/ARM printf 用法说明
2022-07-17 00:16:00 【chip1234】
希望通过printf() 将内容打印到串口并输出,需要先将串口初始化,设置好波特率,pin 脚模式,中断等,然后有两种方式:
勾选 Use MicroLIB. Options for Target --> Target(Tab) -->勾选Use MicroLIB,然后添加如下代码
int fputc(int ch, FILE *f) { while((USART1->SR&0X40)==0);//循环发送,直到发送完毕 USART1->DR = (u8) ch; return ch; }注意:必须勾选Use MicroLIB
添加如下代码,可以不勾选Use MicroLIB。勾选了对打印输出到串口也没有影响的。
#pragma import(__use_no_semihosting) //标准库需要的支持函数 struct __FILE { int handle; }; FILE __stdout; //定义_sys_exit()以避免使用半主机模式 void _sys_exit(int x) { x = x; } //重定义fputc函数 int fputc(int ch, FILE *f) { while((USART1->SR&0X40)==0);//循环发送,直到发送完毕 USART1->DR = (u8) ch; return ch; }
边栏推荐
猜你喜欢
随机推荐
Understand inheritance, polymorphism, abstraction and their concepts
BeanShell脚本获取当前时间
Shell脚本case分支语句、扒匿名登录FTP的max地址
Inverse yuan (I'll add these words if there are too many people using the name)
jmeter连接数据库的方法
30分钟搞懂 HTTP 缓存
InnoDB, MySQL structure, and the difference between the three kinds of deletion
面试:接口和抽象类的区别-简洁的总结
[antv G2] how to add a click event to the line chart (click anywhere to get the value of the point on the line)
Flask template injection
简单记录一下并查集
D - Parity game离散化+带权并查集
Detailed explanation of caduceus project of metauniverse public chain (I): project concept and technical framework of caduceus metaverse protocol
转载:SQL注入常见绕过
Zabbix6.0通过iDRAC,IMM2监控DELL,IBM服务器硬件
UE4 notes
子网划分(详)
最长上升子序列----优化
Cocoon breaking and rebirth of 3D NFT: caduceus decentralized edge rendering technology
Shell脚本整数值比较、逻辑测试、if语句、提取性能监控指标









