#include “stdio.h”
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f) {
if (DEMCR & TRCENA) {
while (ITM_Port32(0) == 0);
ITM_Port8(0) = ch;
}
return(ch);
}
然后就可以用printf 了
测试用ST-LINK V2可以使用, MDK不知道怎么无法显示出打印信息, 在STM32 ST-LINK Utility 中正常打印。
本文介绍了一种在STM32上实现printf打印功能的方法,并通过ST-LINK V2验证了其可行性。文中提供了核心代码片段,包括文件结构定义及fputc函数实现。
5183

被折叠的 条评论
为什么被折叠?



