码迷,mamicode.com
首页 > 其他好文 > 详细

Keil Debug (printf) Viewer

时间:2018-01-28 11:16:24      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:through   for   init   monitored   access   mcr   view   sign   ola   

Debug (printf) Viewer

The Debug (printf) Viewer window displays data streams that are transmitted sequentially through the ITM Stimulus Port 0. Enable ITM Stimulus Port 0.

技术分享图片

To use the Debug (printf) Viewer for tracing:

  1. Add ITM Port register definitions to your source code.
    #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
    
  2. Add an fputc function to your source code that writes to the ITM Port 0 register. The fputc function enables printf to output messages.
    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);
    }
    
  3. Add your debugging trace messages to your source code using printf.
    printf("AD value = 0x%04X\r\n", AD_value);
    
  4. Set the ITM Port 0 to capture the information. Clear the Port 7..0 privilege bit to access ITM Port 0 from User mode.

    技术分享图片

  5. Open the View - Serial Windows - Debug (printf) Viewer window.

技术分享图片 Note

 

http://www.keil.com/support/man/docs/jlink/jlink_trace_itm_viewer.htm

https://www.douban.com/note/248637026/

Keil Debug (printf) Viewer

标签:through   for   init   monitored   access   mcr   view   sign   ola   

原文地址:https://www.cnblogs.com/sinferwu/p/8367686.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!