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

    Monitor-mode debugging

    Monitor-mode debugging describes the capability of the CPU to maintain essential functionality while being debugged.

    Contact us
    Downloads
    Documentation
    SEGGER Debug & Trace Probes
    1. 1.Use cases
    2. 2.How monitor-mode debugging works
      1. 2.1.Supported CPUs
    3. 3.The debugger / IDE side
      1. 3.1.Considerations/limitations
      2. 3.2.Monitor for other IDEs
    4. 4.Example project
    5. 5.FAQ

    Overview

    Monitor-mode debugging describes the ability of a CPU to maintain essential functionality while being debugged. This is particularly important in systems where hardware components such as motors must continue running or communication links need to remain active.

    For most common CPUs, the default approach is halt-mode debugging. In this mode, the CPU halts on a debug request, causing the user application and, depending on the architecture, also peripheral components to stop executing.

    In certain applications and environments, however, it is necessary for parts of the application to continue running while the CPU is in debug mode and another part of the software is being debugged.

    This is where monitor-mode debugging provides a significant improvement.


    Use cases

    There are several scenarios in which monitor-mode debugging is the only viable way to debug an application.

    Abstract representation of a circuit board with intricate lines and patterns. The image features a microprocessor prominently, set against a dark background, emphasizing the technology theme. The overall tone is sleek and modern, suggesting advancements in electronics and computing.

    Motor control with PWM

    In applications that include motor control using pulse width modulation, halting the CPU also stops the PWM units. This can leave the motor control logic in an undefined or potentially unsafe state. Monitor-mode debugging allows the PWM-related code to continue running while the rest of the application is halted and debugged.

    Abstract representation of a circuit board with intricate lines and patterns. The image features a microprocessor prominently, set against a dark background, emphasizing the technology theme. The overall tone is sleek and modern, suggesting advancements in electronics and computing.

    Bluetooth communication

    In applications that rely on Bluetooth communication, halting the entire application would cause the connection to drop. Monitor-mode debugging allows Bluetooth keep-alive interrupts to continue running, maintaining low-level communication while the remainder of the application is halted and debugged.

    Abstract representation of a circuit board with intricate lines and patterns. The image features a microprocessor prominently, set against a dark background, emphasizing the technology theme. The overall tone is sleek and modern, suggesting advancements in electronics and computing.

    Ethernet networking

    In Ethernet-based applications, halting the CPU can cause the IP stack to become unresponsive, preventing packets from being received, including keep-alive traffic. Monitor-mode debugging enables developers to analyze such systems while maintaining essential network functionality.

    Abstract representation of a circuit board with intricate lines and patterns. The image features a microprocessor prominently, set against a dark background, emphasizing the technology theme. The overall tone is sleek and modern, suggesting advancements in electronics and computing.

    CAN bus communication

    In applications that use CAN bus communication, halting the CPU would result in lost messages. When using monitor-mode debugging, the CPU can continue to handle incoming CAN messages while the main application remains halted.


    How monitor-mode debugging works

    In contrast to halt-mode debugging, in monitor-mode debugging the target CPU does not halt on a debug request but takes a debug interrupt instead and jumps to a specific debug interrupt handler which then handles the communication with J-Link and also some low-level application maintenance that may be needed to be done while the application is halted. So technically, the CPU is still running and executing the code while the application itself is halted, allowing it to still handle some interrupts as well as some synchronous maintenance operation that can be done within the monitor code.

    The monitor code consists of the following parts:

    • A generic monitor that handles communication with J-Link. This part is delivered by SEGGER and should not be modified by the user.
    • A custom monitor part providing some functions that can be filled in by the user. SEGGER delivers a template for this part.

    The custom monitor part provides the following functions where the user can add functionality/maintenance which needs to be done in debug mode:

    • JLINK_MONITOR_OnExit(): Called once just before leaving the monitor and restarting the target application.
    • JLINK_MONITOR_OnEnter(): Called once just before entering the monitor. Target application is already stopped at this point.
    • JLINK_MONITOR_OnPoll(): Called periodically while the CPU is in debug mode.


    The monitor modules simply need to be compiled, linked, and downloaded with the application. For limitations on what can be done in the different functions of the custom monitor part, please refer to the J-Link User Guide.

    Supported CPUs

    Whether monitor-mode debugging can be supported for a specific device depends on whether the CPU architecture defines monitor-mode support or not. In case of doubt if a specific CPU is or can be supported, please get in touch with support@segger.com. Currently, the following CPUs are supported for monitor-mode debugging:

    • Cortex-M3
    • Cortex-M4
    • Cortex-M7
    • Cortex-M23
    • Cortex-M33
    • Cortex-M55
    • Cortex-M85

    The debugger / IDE side

    On the debugger / IDE side, no changes are required to support monitor-mode debugging. The IDE will recognize no difference between traditional halt-mode debugging and monitor-mode debugging.

    For the best debug experience, we recommend using Embedded Studio or Ozone.

    Considerations/limitations

    There are certain considerations and limitations to be aware of when using monitor mode debugging. For example, the monitor itself and the periodic actions it performs cannot be debugged. A detailed description of all considerations and limitations can be found in the J-Link User Guide.

    Monitor for other IDEs

    Since the monitor code runs directly on the target and is implemented in assembly language, it differs slightly between compiler environments. The monitor has been ported to the following compilers and IDEs so far:

    • SEGGER Embedded Studio (GCC)
    • Any GCC based environment (GCC)
    • IAR EWARM (IAR ARM compiler)
    • Keil MDK-ARM (ARM compiler)

    In SEGGER Embedded Studio, monitor mode is available through the sample project linked below. Monitor ports for compilers and IDEs other than SEGGER Embedded Studio are available on request via the J-Link download page.


    Example project

    In the following, a example project for SEGGER Embedded Studio can be downloaded that demonstrates:

    • How to use monitor mode in Embedded Studio
    • How to have a specific interrupt keep firing while the main application is halted and the monitor is active

    For more detailed explanations how to bring the project up and running on a specific hardware, please refer to the readme that comes with the project.

    Download example project


    FAQ

    I am using SEGGER RTT. Can it be used together with monitor-mode debugging?

    Yes. SEGGER RTT works seamlessly with monitor mode debugging. No changes are required on either the debugger or the application side.

    I am using a CPU with a specific core. Can monitor-mode debugging be supported?

    If the CPU core is not listed above, please contact support@segger.com to check if monitor-mode debugging support can be added for this CPU.

    Do all J-Links support monitor-mode debugging?

    Monitor-mode debugging is available on all current J-Links, including J-Link PLUS, J-Link Ultra, and J-Link Pro, and is also supported by J-Trace. J-Link BASE and on-board J-Links support monitor mode in evaluation mode only.

    • 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 而访问境外网站,是否继续?