Skip to main content
  • 产品
  • Software evaluation
  • 下载
  • Free utilities
  • 购买
  • 芯片厂商
  • 支持
  • 关于我们
  • Search
  • 工作机会
  • 新闻简报
  • 联系我们
  • J-Link debug probes
  • J-Link SWO Viewer

    J-Link SWO Viewer

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

    Contact us
    Downloads
    Documentation
    SEGGER Debug & Trace Probes
    1. 1.Licensing
    2. 2.System requirements
    3. 3.Technical background
    4. 4.Example code
    5. 5.Latest news

    Overview

    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.

    Licensing

    The J-Link SWO Viewer comes as part of the J-Link Software and Documentation Package. The software package is free for any J-Link or J-Trace device and can be downloaded here:

    DownloadJ-Link Software and Documentation Pack

    System requirements

    Supported OS
    WindowsMicrosoft Windows (x86/x64)
    macOSmacOS (x86/Apple Silicon)
    LinuxLinux (x86/x64/Arm)

    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++);
      }
    }

    Latest news

    2025
    Dec.08
    J-Link
    Image featuring three SEGGER programming tools: Flasher, J-Trace, and J-Link, labeled with their functions. The background includes a circuit design and the Alif Semiconductor logo, emphasizing support for the Alif Semi E4, E6, and E8 series.

    SEGGER announces debug, trace, and programming support for select Alif Ensemble series devices

    SEGGER’s J-Link debug and J-Trace streaming trace probes, as well as its Flasher in-system programmers now support Alif Semiconductor’s E4, E6, and E8 series of fusion processors, which enable generative AI in Edge devices.

    [Read more...]

    All news

    • Release notes
    • Update notification
    • Pricing
    • Support
    • Silicon vendor resources
    • J-Link Prime

    全球总部

    德国: SEGGER Microcontroller GmbH

    地址: Ecolab-Allee 5
    40789 Monheim am Rhein, Germany
    电邮: info@segger.com
    电话: +49-2173-99312-0
    传真: +49-2173-99312-28

    网点分布

    中国:哲戈微系统科技(上海)有限公司

    地址: 中国上海市闵行区秀涟路133号
    大虹桥国际A 栋218室
    邮编201199
    电邮: china@segger.com
    电话: +86-133-619-907-60


    简易信息聚合

    通过ISO 9001认证

    ISO 9001

    30多年的嵌入式行业经验

    First-class embedded software tools since 1992
    • 版本说明
    • 免责声明
    • 行为准则
    • 隐私策略
    • 沪ICP备2022005181号
    • 沪公网安备 31011202014525号
    © 2025 SEGGER - 版权所有.

    您即将离开 segger.cn 而访问境外网站,是否继续?