Configure Swo Output After Device Reset - Segger J-Link User Manual

Hide thumbs Also See for J-Link:
Table of Contents

Advertisement

106
Syntax
-swofreq <SWOFreq>
Example
-swofreq 6000
3.8.3

Configure SWO output after device reset

In some situations it might happen that the target application is reset and it is desired to log
the SWO output of the target after reset during the booting process. For such situations, the
target application itself needs to initialize the CPU for SWO output, since the SWO Viewer
is not restarted but continuously running.
Example code for enabling SWO out of the target application
#define
ITM_ENA
#define
ITM_TPR
#define
ITM_TCR
#define
ITM_LSR
#define
DHCSR
#define
DEMCR
#define
TPIU_ACPR
#define
TPIU_SPPR
#define
DWT_CTRL
#define
FFCR
U32 _ITMPort
U32 TargetDiv = 1;
static void
_EnableSWO() {
U32 StimulusRegs;
//
// Enable access to SWO registers
//
DEMCR |=
(1
ITM_LSR = 0xC5ACCE55;
//
// Initially disable ITM and stimulus port
// To make sure that nothing is transferred via SWO
// when changing the SWO prescaler etc.
//
StimulusRegs = ITM_ENA;
StimulusRegs &=
ITM_ENA = StimulusRegs;
ITM_TCR = 0;
//
// Initialize SWO (prescaler, etc.)
//
TPIU_SPPR = 0x00000002;
TPIU_ACPR = TargetDiv - 1;
ITM_TPR = 0x00000000;
DWT_CTRL = 0x400003FE;
FFCR = 0x00000100;
//
// Enable ITM and stimulus port
//
ITM_TCR = 0x1000D;
ITM_ENA = StimulusRegs |
J-Link / J-Trace (UM08001)
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
(*(volatile unsigned
= 0;
// The stimulus port from which SWO data is received
// and displayed.
// Has to be calculated according to
// the CPU speed and the output baud rate
<< 24);
~(1
<< _ITMPort);
// Disable ITM stimulus port
// Disable ITM
// Select NRZ mode
// Example: 72/48 = 1,5 MHz
// Enable ITM
(1
<< _ITMPort);
CHAPTER 3
int*)0xE0000E00)
int*)0xE0000E40)
int*)0xE0000E80)
int*)0xE0000FB0)
int*)0xE000EDF0)
int*)0xE000EDFC)
int*)0xE0040010)
int*)0xE00400F0)
int*)0xE0001000)
int*)0xE0040304)
// Enable ITM stimulus port
© 2004-2017 SEGGER Microcontroller GmbH & Co. KG
J-Link SWO Viewer
// ITM Enable
// Trace Privilege
// Register
// ITM Trace Control Reg.
// ITM Lock Status
// Register
// Debug register
// Debug register
// Async Clock
// prescaler register
// Selected Pin Protocol
// Register
// DWT Control Register
// Formatter and flush
// Control Register

Advertisement

Table of Contents

Troubleshooting

loading
Need help?

Need help?

Do you have a question about the J-Link and is the answer not in the manual?

This manual is also suitable for:

J-trace

Table of Contents

Save PDF