分享

Keil ARM

 whlky 2016-08-01

参考资料:http://www./support/man/docs/jlink/jlink_trace_itm_viewer.htm

 

 

1.Target Options -> Debug -> Settings(JLink) -> Debug里ort选择SW模式

2.在Target Options -> Debug -> Settings(JLink) -> Trace里选择Enable

3.Core freq设为120MHz(以LPC1788为例)

4. 设置ITM Port的值如下所示

5.在工程中添加.c文件如下

复制代码
#include "stdio.h"

#define ITM_Port8(n)    (*((volatile unsigned char *)(0xE0000000+4*n)))
#define ITM_Port16(n)   (*((volatile unsigned short*)(0xE0000000+4*n)))
#define ITM_Port32(n)   (*((volatile unsigned long *)(0xE0000000+4*n)))

#define DEMCR           (*((volatile unsigned long *)(0xE000EDFC)))
#define TRCENA          0x01000000

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);
}
复制代码

6.用Debug模式运行工程,Debug (printf) Viewer中即可以查看printf的输出信息。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多