Skip to main content
  • Products
  • Evaluate our Software
  • Downloads
  • Free Utilities
  • Purchase
  • Support
  • About Us
  • Blog
  • Forum
  • Search
    • Contact Us
    • Forum
    • Wiki
    • Web Shop
    • Newsletter
    • RSS
  •  Jobs
  •  Blog
  • J-Link
  • J-Link SWO Viewer
  • Technology
  • Accessories
  • Tools
  • Models
J-Link product icon SEGGER blue stack

J-Link SWO Viewer

J-Link SWO Viewer is a tool which allows showing terminal output of the target performed via the SWO pin.

J-Link SWO Viewer is a tool which allows showing terminal output of the target performed via the SWO pin. It can be used without a debugger when the application runs stand-alone to still perform some log output or side by side with a debugger such as GDB or GDB/Eclipse which does not support terminal output via SWO.

SWOViewer is part of the latest J-Link software package which can be downloaded free of charge. It does not require a license and can be used on any current J-Link model, from J-Link Lite to J-Link Pro.

Technical Background

SWO is a dedicated pin of ARM's Cortex-M debug interface.
While it can be used to output various information in real time by the CPU, it's main usage is terminal I/O in real time with very low intrusion.

Most programs can perform debug outputs without losing their real time behavior.

SWO Viewer

Example Code

Simple implementation for output via SWO for Cortex-M processors. It can be used with any IDE. This sample implementation ensures that output via SWO is enabled in order to guarantee that the application does not hang.

/*********************************************************************
*
*       Prototypes (to be placed in a header file such as SWO.h)
*/
void SWO_PrintChar  (char c);
void SWO_PrintString(const char *s);

/*********************************************************************
*
*       Defines for Cortex-M debug unit
*/
#define ITM_STIM_U32 (*(volatile unsigned int*)0xE0000000)    // Stimulus Port Register word acces
#define ITM_STIM_U8  (*(volatile         char*)0xE0000000)    // Stimulus Port Register byte acces
#define ITM_ENA      (*(volatile unsigned int*)0xE0000E00)    // Trace Enable Ports Register
#define ITM_TCR      (*(volatile unsigned int*)0xE0000E80)    // Trace control register

/*********************************************************************
*
*       SWO_PrintChar()
*
* Function description
*   Checks if SWO is set up. If it is not, return,
*    to avoid program hangs if no debugger is connected.
*   If it is set up, print a character to the ITM_STIM register
*    in order to provide data for SWO.
* Parameters
*   c:    The Chacracter to be printed.
* Notes
*   Additional checks for device specific registers can be added.
*/
void SWO_PrintChar(char c) {
  //
  // Check if ITM_TCR.ITMENA is set
  //
  if ((ITM_TCR & 1) == 0) {
    return;
  }
  //
  // Check if stimulus port is enabled
  //
  if ((ITM_ENA & 1) == 0) {
    return;
  }
  //
  // Wait until STIMx is ready,
  // then send data
  //
  while ((ITM_STIM_U8 & 1) == 0);
  ITM_STIM_U8 = c;
}

/*********************************************************************
*
*       SWO_PrintString()
*
* Function description
*   Print a string via SWO.
*
*/
void SWO_PrintString(const char *s) {
  //
  // Print out character per character
  //
  while (*s) {
    SWO_PrintChar(*s++);
  }
}

More Information

Purchase

  • Pricing

Technology

  • Control Panel
  • Flash Breakpoints
  • Flash Download
  • Interface Description
  • J-Link SDK
  • Monitor Mode Debugging
  • Power Profiling
  • Real-Time Transfer (RTT)
  • CPUs and Devices
  • IDEs

Accessories

  • Adapters
  • Isolators

Tools

  • Ozone - J-Link Debugger
  • J-Link Configurator
  • J-Link GDB Server
  • J-Link Remote Server
  • J-Link Commander
  • J-Mem
  • J-Link SWO Viewer
  • J-Scope
  • J-Flash
  • J-Flash SPI
  • J-Link RDI
  • RTT Viewer
  • SystemView
  • Terms of Use
  • Third Party applications

Models

  • Model Overview
  • J-Link PRO
  • J-Link ULTRA+
  • J-Link WiFi
  • J-Link PLUS
  • J-Link BASE
  • J-Link EDU
  • J-Link EDU Mini
  • J-Link OB
  • J-Link LITE
  • Other J-Links
  • Related products

About us

  • The Company
  • Partners
  • Job Offers
  • Media
  • Contact us

Support

  • Technical Support
  • Blog
  • Forum
  • Wiki

Downloads

  • Application Notes
  • Embedded Studio
  • embOS
  • emCompress
  • emCrypt
  • emFile
  • emLib
  • emLoad
  • emModbus
  • emNet
  • emPower
  • emSecure
  • emSSH
  • emSSL
  • emUSB-Device
  • emUSB-Host
  • emWin
  • Flasher
  • Free Utilities
  • IoT
  • J-Link / J-Trace
  • SystemView
  • CE / REACH

Social Media

Headquarters

SEGGER Microcontroller GmbH

Ecolab-Allee 5
40789 Monheim am Rhein, Germany
info@segger.com
Tel.: +49-2173-99312-0
Fax: +49-2173-99312-28

Locations

USA: SEGGER Microcontroller Systems LLC

Boston area
101 Suffolk Lane
Gardner, MA 01440, USA
us-east@segger.com
Tel.: +1-978-874-0299
Fax: +1-978-874-0599

Silicon Valley
Milpitas, CA 95035, USA
us-west@segger.com
Tel.: +1-408-767-4068

China: SEGGER Microcontroller China Co., Ltd.

Room 218, Block A, Dahongqiaoguoji
No. 133 Xiulian Road
Minhang District, Shanghai 201199, China
china@segger.com
Tel.: +86-133-619-907-60

ISO 9001 certified

ISO 9001

25+ years of experience

embedded experts 25+ years
  • Imprint
  • Disclaimer
  • Privacy Policy

© 2021 SEGGER - All rights reserved.