cortex-m3,4 ITM printf 使用

来源:互联网 发布:林心如私生活糜烂 知乎 编辑:程序博客网 时间:2024/06/06 07:16

#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 中正常打印。

0 0