4007 views|4 replies

227

Posts

0

Resources
The OP
 

IAR EWARM's SWO Trace debugging function [Copy link]

 

The SWD debug interface is a debug interface proposed by ARM. Compared with the traditional JTAG interface, it uses fewer signal pins. The SWD debug interface signal definition is shown in the red line in the figure below:

Figure 1

Some Cortex-M3/M4/M7 chips support SWO Trace function, which have built-in DWT, ITM (Instrument Trace Macrocell) and other units. One of the main uses of ITM is to support information output. In addition, DWT also tracks the entry and exit of interrupts and samples the PC counter.

IAR supports SWO Trace debugging, a powerful debugging function that uses the SWO serial line in the SWD interface to output the trace information generated during debugging. Using SWO debugging requires connecting the SWO pin of the debugger to the SWO of the chip.

This article will briefly introduce several practical functions of SWO Trace debugging.

Hardware requirements for using SWO Trace:

1. The emulator used supports SWD debug interface and SWO serial communication.

2. The chip supports the SWD debug interface. Most mainstream core chips such as M3/M4/M7 support it, and the SWO pin on the chip should be connected to the SWO pin of the hardware debug interface.

Software settings using SWO Trace:

Select the SWD interface to connect in the debugger configuration.

Figure 2

SWO debugging function example:

(1). Use Terminal I/O to print debugging information

The Terminal I/O function provided by IAR can display the information output by the printf statement in the function in the Terminal I/O window. There are two ways to output printf information, semi-host mode and SWO mode. The information output rate is slow in semi-host mode, and when using SWO mode for information output, the speed is very fast, which is suitable when there is a large amount of information to be output. You can check the use of SWO mode in General Options->Library Configuration. The Terminal I/O window is opened from the View menu after entering the debugging environment.

Figure 3

(2). Real-time display of variable value changes

With SWO debugging, you can monitor the value changes of global variables in real time and display them in a graphical way. TestPoint in the figure below is a global variable. Right-click on the variable and select "Data Log" to set a data logging breakpoint.

Figure 4

Open the breakpoint window through the view->breakpoint option, right-click the breakpoint and click the Edit option to edit it, and select to trigger the data recording breakpoint when the variable is overwritten by Write.

Figure 5

Figure 6

Open the Data Log and Timeline windows from the debug menu of the simulator used, such as I-jet, right-click the window and select "Enable", then click "Go" to run the program at full speed. The data log window will display the tracking record of the global variable TestPoint in real time. The displayed data includes information such as timestamp, variable value and variable address.

Figure 7

In the Data Log column of the Timeline window, right-click again and select "Enable" to enable graphical display. You can get the real-time change view of the TestPoint variable value as shown below.

Figure 8

(3). Measure code execution time

Because the information displayed in the Data Log window contains the timestamp when the variable value changes, this can be used to measure the execution time of the function. As shown in the figure below, a global variable TimeStamp is added before and after the sorting function NumberSorting() is executed as a monitoring variable for measuring the running time.

Figure 9

Fig.10

The NumberSorting function modifies the value of the TimeStamp variable before and after execution. The execution time of the function can be calculated based on the change time of the TimeStamp value in the Data Log window. The time taken for TimeStamp to change from 0x05 to 0x0A is:

t = 21576.23 - 20992.01 = 584.22us

From this we can know that the time taken to execute the sorting function NumberSorting() is 584.22us.

Latest reply

Do more, your articles are all very good.   Details Published on 2020-11-11 22:36
Personal signature

欢迎关注“麦克泰技术”

 

7422

Posts

2

Resources
2
 

Interesting, I've saved it. I've never used SWO and didn't realize it has so many features.

 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

227

Posts

0

Resources
3
 
freebsder posted on 2020-11-10 22:47 Interesting, I have saved it. I have never used SWO and I didn’t expect it to have so many features.

 
Personal signature

欢迎关注“麦克泰技术”

 
 

7422

Posts

2

Resources
4
 

Do more, your articles are all very good.

 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

227

Posts

0

Resources
5
 
freebsder posted on 2020-11-11 22:36 Do more, your articles are all very good.

Great, thank you for your appreciation, you have a good eye.

 
Personal signature

欢迎关注“麦克泰技术”

 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list