TN0132 - STM32 Serial Wire Viewer (SWV) and Embedded Trace Macrocell (ETM)capabilities. Examples and technical note..PDF

(650 KB) Pobierz
STM32 Serial Wire Viewer and ETM capabilities with EWARM 5.40 and MDK-ARM 3.70
TN0132
Technical note
STM32 Serial Wire Viewer and ETM
capabilities with EWARM 5.40 and MDK-ARM 3.70
Introduction
This document presents Serial Wire Viewer (SWV) and Embedded Trace Macrocell (ETM)
capabilities with these toolchains in various configurations:
●
RVMDK 3.70 (RealView ® Microcontroller Development Kit from Keil™)
●
EWARM 5.40 (Embedded Workbench® for ARM® from IAR Systems)
The STM32 provides a 4-bit ETM port as well as a Serial Wire Viewer port.
In general, the ETM is used to find problems using heavy duty trace debugging such as
looking for difficult bugs, while the SWV is used to provide a low cost method of obtaining
information from inside the MCU using ARM CoreSight™ technology.
January 2010
Doc ID 16243 Rev 1
1/16
273898541.003.png
SWV feature capabilities
TN0132
1
SWV feature capabilities
1.1
Introduction
Serial Wire Viewer is the ability of the ARM™ core to send real-time trace information out
via a single wire port called the Serial Wire Output (SWO). The trace information is in
several familiar formats such as:
●
Instrumentation Trace Macrocell (ITM) for application driven trace source that supports
printf style debugging.
●
Data Watchpoint and Trace (DWT) for variable monitoring and PC-sampling, which can
in turn be used to periodically output the PC (sampled) or various CPU internal
counters and to obtain profiling information from the target:
– Program Counter sampling.
– Data read and write cycles.
– Variable and peripheral values.
– Event counters.
– Exception entry and return.
●
Timestamps and CPU cycles are emitted relative to packets.
Our focus is on the analysis of the serial wire port’s output information, in particular
configurations, and to highlight its capabilities of providing information and data at the high
speed that the STM32 runs at.
1.2
Context
This manual comes with a .zip file containing the subdirectories and files that make up the
core of application examples.
These application examples are configured at 72 MHz (maximum frequency of the STM32
MCU) and highlight the following SWV features:
●
Data access
●
Interrupt
●
Program counter sampling
●
Printf
Each application example’s folder contains:
●
inc subfolder containing the example header files
●
src subfolder containing the example source files
●
project subfolder containing two projects that compile the example files:
– EWARMv5 containing the project for the EWARM toolchain
– ARM-MDK containing the project for the ARM-MDK toolchain
These examples are tested in the following hardware and software conditions:
●
SW/HW toolchain: EWARM 5.40/JLINK v6 and ARM-MDK 3.70/ULINK2
●
Target board: STM3210E-Eval Rev.A
●
Office PC Pentium® 4 CPU 3.20 GHz, 504 MB of RAM, SP2
●
SW clock autodetected
2/16
Doc ID 16243 Rev 1
273898541.004.png
TN0132
SWV feature capabilities
1.3
Program counter (PC) sample
The display of program counter values is useful for program flow change, profile analysis
and determining where the CPU might be caught in an infinite loop. Profile analysis gives a
helpful indication where the CPU is spending its time.
Nevertheless in some conditions, the SWO and toochains are not capable of providing every
program counter value because of the high speed that the STM32 runs at. Section 1.3.1 and
Section 1.3.2 illustrate the limitations detected with both ARM-MDK and EWARM toolchains
with particular configurations.
1.3.1
ARM-MDK / ULINK2 toolchain example
Running the PC Sampling example using the ARM-MDK toolchain highlights that if the PC
sampling prescaler is equal to 7*1024 (10044 samples per second), a hardware buffer
overrun occurs. This is due to the fact that the USB cannot accept data at the speed ULINK2
is sending it (see Figure 1 ).
Figure 1. ARM-MDK PC samples: Hardware buffer overrun
By decreasing the prescaler value until 3*1024 (23437 samples per second), an overflow
occurs due to the fact that the SWO communication channel is not fast enough to handle
that much data. Consequently, an overflow is detected as illustrated by Figure 2 .
Doc ID 16243 Rev 1
3/16
273898541.005.png
SWV feature capabilities
TN0132
Figure 2. ARM-MDK PC samples: Overflow
1.3.2
EWARM / J-Link toolchain example
Running the PC Sampling example using the EWARM toolchain highlights that when the
Rate (the number of samples per second) is set to 86538, the SWO communication
channel is not fast enough to handle that much data. Consequently, an Overflow is detected,
illustrated by Figure 3 .
Figure 3. EWARM PC Samples: Overflow
1.4
Read and write data frames
Read and write data frames can be displayed giving the address of the responsible
instruction, the data value transferred, the data address and timestamps in both core cycles
and seconds. Figure 4 shows a series of data reads and writes showing these attributes.
4/16
Doc ID 16243 Rev 1
273898541.006.png 273898541.001.png
TN0132
SWV feature capabilities
1.4.1
ARM-MDK / ULINK2 toolchain example
Running the Data Access example using the ARM-MDK toolchain highlights that if a delay of
less than 310 µs is inserted before incrementing the j variable, a hardware buffer overrun
occurs. This is due to the fact that the USB cannot accept data access at the speed the
ULINK2 is sending it (see Figure 4 ).
By decreasing the delay until 155 µs, an overflow occurs because the SWO communication
channel is not fast enough to handle that much data access, for example, some values are
not displayed in the trace record window (see Figure 5 ). To avoid these two problems in the
Data Access example, the user should insert a delay greater than 310 µs.
Figure 4. ARM-MDK data read access: Hardware buffer overrun
Figure 5. ARM-MDK data read access: Overflow
Doc ID 16243 Rev 1
5/16
273898541.002.png
Zgłoś jeśli naruszono regulamin