Keil debugging techniques and alternative printf (SWO function)
One of the basic needs of the embedded software development through the terminal to output debugging information, generally two ways to achieve:
one is the COM port on the UART and PC using a serial cable connecting plate through the PC HyperTerminal to view the debugging information;
Another mechanism is the use of semi-host, but it may not be used in tool chain support.
Cortex-M3 core-based software debug break this limit, the Cortex-M3 core provides
a ITM (Instrumentation TraceMacrocell) interface debugging theITM data received by the SWO pin SWV (Serial Wire Viewer).
ITM 32 common data channel, based on the implementation the CMSIS requirements as the debugging output terminal to output debugging information,
channel 31 for the operating system (privileged mode access) channel 0.
In core_cm3 h the defined ITM_SendChar () function by calling the function to rewrite fputc print debugging information in the application by printf,
these debugging information can be viewed by the ITM Viewer.
With this implementation, embedded software developers can not configure the serial port
and use the terminal debugging software output debugging information to some extent reduce the workload.
Basic concepts:
SWD
The J-Link and J-Trace support ARMs Serial WireDebug (SWD).
SWD replaces the 5-pin JTAG port with a clock (SWDCLK) and a single bi-directional data pin (SWDIO),
providing all thenormal JTAG debug and testfunctionality.
Pin 13 of SWD:
SWO - Serial Wire Output trace port. (Optional, not required for SWD communication.)
SWO
J-Link can be used with devices that supportSerial Wire Output (SWO).
Serial Wire Output (SWO) support meanssupport for a single pin output signal from the core. It iscurrently tested with Cortex-M3 only.
SWV
The Instrumentation Trace Macrocell (ITM) andSerial Wire Output (SWO) can be used to form a Serial Wire Viewer (SWV).
The Serial Wire Viewer provides a low cost method ofobtaining information from inside the MCU.
The SWO can output tracedata in two output formats, but only one output mechanism is validat any one time.
The 2 defined encodings are UART and Manchester.
The current J-Link implementation only supports UART encoding.
Serial Wire Viewer uses the SWO pin to transmit different packetsfor different types of information.
The three sources in theCortex-M3 core which can output information via this pinare:
- Instrumentation Trace Macrocell (ITM) forapplication-driven trace source that supports printf-styledebugging.
It supports 32 different channels, which allow it to beused for other purposes such as real-time kernel information aswell.
- Data Watchpoint and Trace (DWT) for real-timevariable monitoring and PC-sampling,
which can in turn be used toperiodically output the PC or various CPU-internal counters,
whichcan be used to obtain profiling information from thetarget.
- Timestamping. Timestamps are emitted relative topackets.
Debug (printf) Viewer
Home »?Vision Windows >> 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.
Debug Viewer window
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 + * n)))
# Define ITM_Port16 (n) (* ((volatile unsigned short *) (0xE0000000 + * n)))
# Define ITM_Port32 (n) (* ((volatile unsigned long *) (0xE0000000 + * 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 )
{
the
while ( ITM_Port32( ) == )
;
ITM_Port8( ) = 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.
ITM Stimulus Port 0
Open the View - Serial Windows - Debug (printf) Viewer window.
Note
ITM Stimulus Ports can be monitored in the Instruction Trace Window, where ITM Port 0 is shown as well.
Consult Configure Cortex-M Target of the MDK-Primer for information on how to retarget the output.
Keil debugging techniques and alternative printf (SWO function)的更多相关文章
- <<linux device driver,third edition>> Chapter 4:Debugging Techniques
Debugging by Printing printk lets you classify messages accoring to their severity by associating di ...
- 在keil中使用printf()函数的要点
在keil中printf默认是向串口中发送数据的,所以,如果应用该函数,必须先初始化串口,否则可能引起死机的情况,并且在printf之前应该先将TI置位,摘抄原因如下: 1.printf函数是调用pu ...
- printf in KEIL C51
转自:http://blog.csdn.net/it1988888/article/details/8821713 在keil中printf默认是向串口中发送数据的,所以,如果应用该函数,必须先初始化 ...
- Keil C51 的printf
转自:http://blog.csdn.net/zhanglianpin/article/details/44779009 在Keil C51 中使用printf ,首先需要重新实现 putchar( ...
- 使用printf函数实现串口信息打印——设置IAR和Keil的Options
在Keil和IAR中都可以使用printf函数,但两者设置的方法不一样.以下分别是IAR和Keil的设置. 下面是Keil的设置. 选中Options--->Target--->Code ...
- AMD64 Instruction-Level Debugging With dbx
http://www.oracle.com/technetwork/server-storage/solarisstudio/documentation/amd64-dbx-364568.html A ...
- STM32F103C8T6最小板搞定CMSIS-DAP和SWO功能
转载:http://www.stmcu.org.cn/module/forum/forum.php?mod=viewthread&tid=616081&extra=page%3D&am ...
- 初学单片机:Proteus介绍、Proteus与Keil联调(Windows10环境下)
Proteus是一个仿真软件,可以在里面设计电路并模拟测试,也可生成PCB的布线等等,反正就是强大的不行.初学单片机,除了开发板,这个仿真器就是一个很好的调式环境.软件安装信息: Proteus 8. ...
- Named function expressions demystified
Introduction Surprisingly, a topic of named function expressions doesn't seem to be covered well eno ...
随机推荐
- shell脚本常用参数
shell 脚本 常用参数 #!/bin/sh # 在脚本第一行脚本头 # sh为当前系统默认shell,可指定为bash等shell sh -x # 执行过程 sh -n # 检查语法 (a=bbk ...
- oracel回收站清理
从powerdesigner中往oracle中导入表,出现了很多类似“BIN$Z35FPY7eFZDgUKjAC94NkA==$0 ”这样的表名, 原因是删除表的时候没有彻底的删除表,而是把表放入回收 ...
- 存储之磁盘阵列RAID
存储之磁盘阵列RAID RAID是由美国加州大学伯克利分校的D.A. Patterson教授在1988年提出的.RAID名为独立冗余磁盘阵列(RedundantArray of Indepe ...
- UART中的硬件流控RTS与CTS【转】
转自:http://blog.csdn.net/zeroboundary/article/details/8966586 5/23/2013 5:13:04 PM at rock-chips insh ...
- linux磁盘空间查看inode
服务器一般是要求长期连续运行的,自动执行任务生成的各种文件及日志,可能使空间占满,从而造成业务故障,所以要定时清理. 一般来说,Linux空间占满有如两种情况: 1.空间被占满了 用df -k 可以看 ...
- elasticsearch安装kibana插件
1.下载 2.解压将解压后的文件放到D:\DevTools\kibana-4.6.0-windows-x86路径下 3.修改配置文件D:\DevTools\kibana-4.6.0-windows-x ...
- springcloud常见问题处理
无法在任何已知服务器上执行请求. 原因是注册中心未启动.在使用springcloud搭建微服务时,一定要先启动注册中心,再启动服务端和客户端.具体报错如下: com.netflix.discovery ...
- poj2148
题意:给出若干个没有公共面积的多边形,几个多边形可能属于同一个国家,要求给这个地图染色,同一个国家用相同的颜色,相邻国家不能用相同颜色.问最少需要多少种颜色. 分析:计算几何+搜索.先判断哪些多边形是 ...
- Redis Scan命令
原地址:https://www.cnblogs.com/tekkaman/p/4887293.html [Redis Scan命令] SCAN cursor [MATCH pattern] [COUN ...
- 防雪崩利器:熔断器 Hystrix 的原理与使用
1.概述 分布式系统中经常会出现某个基础服务不可用造成整个系统不可用的情况, 这种现象被称为服务雪崩效应. 为了应对服务雪崩, 一种常见的做法是手动服务降级. 而Hystrix的出现,给我们提供了另一 ...