Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (32 sloc) 3.75 KB

Monitor Mode Debugging in Segger embedded studios

Segger Embedded Studios has a better integration with MMD than Keil.


  1. Unzip/clone into SDK14.2/examples/ble_peripheral

  2. Open the ses project file ble_app_blinky_pca10040_s132.emProject

  3. Compile the example.

  4. Flash the application to the nRF52DK via ses. NOTE: In SES you have the option to flash additional files, in this example the S132 SoftDevice is flashed automatically. See 'Project->Edit Options->Debug->Loader->Additional Load File'

  5. Enter debug mode.

NOTE: When prompted with the dialog box 'Monitor Mode missing license' you need to press 'Yes'.


  1. Start code execution.

  2. Open nRF Connect and connect to 'NORDIC_BLINKY'. Expand the 'Nordic LED Button Service' and enable notifications for the Button characteristics (press the three downward pointing arrows button).

  3. Press 'Button 1' on the nRF52DK and verify that the Button characteristic's Value field appears and changes value from 'Button pressed' to 'Button released' when pushing the button.

  4. Stop code execution.

  5. Verify that the button value in nRF Connect does not change when pressing 'Button 1'

  6. Start code execution and verify that the value in nRF Connect now changes when pressing 'Button 1'.

  7. You have now verified that the BLE link remained intact despite halting the CPU.

  8. Next I want you to turn on the LED with nRF Connect, then halt the CPU.

  9. While the CPU is halted I want you to turn the LED off in nRF Connect and observe that the LED is still on.

  10. The last thing I want you to do is to restart the CPU and observe that the LED turns off. This means that SoftDevice events are queued when the CPU is halted in MMD mode.

Feel free to play around with single stepping through application code. Now you can finally figure out what your BLE service is actually doing without losing the BLE link ^^

Hey that really is neat, but how do I implement MMD in my project?

The differences between this example and the standard ble_app_blinky demo are listed below:

  1. You need to compile the MMD ISR (DebugMon_Handler) found in JLINK_MONITOR_ISR_SES.s

  2. You need to stop the app_timer (and feed a watchdog if needed) with the MMD utility functions that the assembly coded ISR refers to in JLINK_MONITOR.c and JLINK_MONITOR.h. If you fail to feed a watchdog it will trigger a hardfault followed by a chip reset. The app timer library is the timer used to synchronize many application events like scheduling, timeouts, etc, and it needs to be stopped when we have "halted" the CPU in the MMD ISR. Stopping the app timer is a concious choice by the user, if you want to keep the app timer running you can do that. It is up to the user to decide what to debug.

  3. You need to enable the interrupt by NVIC_SetPriority(DebugMonitor_IRQn, _PRIO_SD_LOW) at the start of your main loop. All the application/protocol_stack context with priority less that the selected priority will be blocked by the DebugMonitor and is available to debug/Step. All the application/protocol_stack context with priority higher than the selected priority will will run uninterrupted irrespective of your debugger state. In this case we will block all low priority app and softdevice interrupts. But the application high priority interrupts and softdevice radio and house_keeping timer interrupts will run uninterrupted

Wait, that's it!?

Youp, that's it.

If you have more questions or want to know more then please write a comment. If you have ideas for improvements you can create an issue an/or pull requests that refers to said issue.

Happy debugging!

You can’t perform that action at this time.