SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: How to Activate the Debug Viewer for Cortex-M0?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

How to Activate the Debug Viewer for Cortex-M0?

Neil Salmon
Last updated: September 16, 2023 10:14 am
Neil Salmon 8 Min Read
Share
SHARE

The Cortex-M0 is an ultra low power 32-bit ARM processor core designed for microcontroller applications. It is optimized for low cost and low power embedded systems. To aid in development and debugging of Cortex-M0 based systems, ARM provides a debug interface and viewer software.

Contents
Prerequisites1. Connect Debug Probe to Target2. Connect Debug Probe to Host Computer3. Configure Debug Host Tools4. Start Debug Session5. Launch Debug ViewerNavigating the Debug ViewerSetting BreakpointsViewing PeripheralsWatching VariablesDebugging TipsSummary

The debug viewer allows developers to view the processor state, memory, peripherals, and other vital debugging information through a graphical user interface on a host computer. This eliminates the need for oscilloscopes, logic analyzers, and other specialized debugging hardware.

Prerequisites

To use the Cortex-M0 debug viewer, you will need:

  • A Cortex-M0 microcontroller or development board
  • Debug probe hardware such as J-Link, ST-Link, or U-Link
  • Debug host tools installed on your computer such as Keil MDK, IAR EWARM, or ARM DS-5
  • Debug viewer software such as ARM DS-5 Debugger
  • Connection between debug probe and Cortex-M0 target
  • Connection between debug probe and host computer

1. Connect Debug Probe to Target

The first step is to connect the debug probe hardware to your Cortex-M0 target microcontroller or development board. This usually involves connecting a 10-pin cable from the debug probe to the debug header on the target board.

For an integrated on-chip debug module, no additional debug hardware may be needed. Consult your microcontroller datasheet for details on the debug interface and connector.

2. Connect Debug Probe to Host Computer

Next, connect the debug probe to your host computer where you have the debug host tools installed. For J-Link and ST-Link, this is usually a USB connection. For U-Link it may be Ethernet. Install any required driver software on the host for your debug probe.

3. Configure Debug Host Tools

Within your debug host tools (Keil MDK, IAR EWARM, DS-5, etc), configure the project to use your debug probe. Select the correct device, typically this involves selecting the ARM core, specifying the specific Cortex-M0 device, and selecting the debug probe.

For Keil MDK go to Options for Target, Debug tab. Select your debug probe and click Settings to configure if needed.

For IAR EWARM, go to Project Options, Debugger tab. Select J-Link/ST-Link/ULINK debug driver and specify device and core.

DS-5 requires configuring the debug driver and target communication tabs under Project Properties.

4. Start Debug Session

With the host tools configured, you can start a debug session. This may be referred to as ‘connecting’ or ‘attaching’. The host tools will initialize communication with the debug probe and begin debugging your target Cortex-M0 system.

In Keil MDK, select Start/Stop Debug Session. Click OK on the popup dialog boxes.

In IAR EWARM, click on Project, Debug to begin a debug session.

In DS-5, select Run, Connect from the Debug menu.

5. Launch Debug Viewer

Once the debug session is started, you can launch the graphical debug viewer. This viewer will display the current state of the Cortex-M0 including register values, memory, peripherals, call stack, breakpoints, and more.

For Keil MDK, select View, System Viewer, Debug from the menu. This will open the debug visualization tool.

In IAR EWARM, select View, Debugging, Debug View to launch the viewer.

In DS-5, select Views, Debug from the Windows menu. Select the Debug Control and other applicable views.

Navigating the Debug Viewer

The debug viewer will show various windows with registers, memory, source code, and other debugging information. Here are some tips for navigating the interface:

  • Registers Window – Displays CPU register values like PC, LR, MSP, PSR, and general purpose registers R0-R12.
  • Memory Windows – Shows Memory Map, Heap, Stack usage. Double click addresses to view.
  • Breakpoints Window – Manage breakpoints. Right click to add/disable/delete.
  • Call Stack Window – Shows stack frames for function calls currently in stack.
  • Source Code Window – View source code, set breakpoints.May require loading symbols.
  • Watch Window – Add variables to watch. Shows current value during debugging.
  • Peripheral Windows – View peripheral registers of UART, Timer, ADC etc.

Use these windows to step through code, analyze data, watch variables, and debug your Cortex-M0 system.

Setting Breakpoints

One fundamental debugging feature is setting breakpoints. This causes the Cortex-M0 to halt execution when a certain line of code or address is reached. To set a breakpoint:

  • In disassembly window, right click on an assembly instruction
  • In source window, double click on a line number
  • In breakpoints window, right click and select Add Breakpoint

When a breakpoint is hit, execution will pause and debugger will show current state. Use Step Into, Step Over, Run commands to move through code.

Viewing Peripherals

The debug viewer provides visibility into the Cortex-M0 peripherals including GPIO, Timers, UART, SPI, I2C and more. For example, to view a UART:

  • Open Peripherals window
  • Expand tree for desired peripheral (UART0, TIM2, etc)
  • View registers such as Control, Data, Status
  • Watch values change when debugging

This allows debugging issues with peripherals without needing external equipment.

Watching Variables

To watch C variables during debugging:

  • Open Watch window
  • Right click and select Add Watch Variable
  • Enter variable name
  • Watch its value change while stepping through code

Variables can also be added from source code window. This is useful for tracking values and catching anomalies.

Debugging Tips

Here are some helpful tips when debugging Cortex-M0 systems with the debug viewer:

  • Use breakpoints wisely – don’t overdo it!
  • Step through code carefully to isolate issues.
  • Inspect registers to check for proper values.
  • Examine call stack to identify functions called.
  • Watch variables and memory to check data flow.
  • Analyze peripherals to verify configuration.
  • Check for exceptions and interrupts being triggered.
  • Capture values during crashes for post-analysis.

With some practice, the Cortex-M0 debug viewer will become an invaluable tool in every embedded developer’s toolkit.

Summary

The Cortex-M0 debug viewer provides a powerful graphical interface for debugging embedded systems without external tools. After connecting the debug probe, configuring the host tools, and starting a debug session, developers can leverage breakpoints, examine registers/memory/peripherals, watch variables, and step through code to analyze program flow and isolate bugs.

Mastering the debug viewer unlocks the ability to develop Cortex-M0 systems faster and more efficiently across the entire embedded product lifecycle.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Cortex M0+, AHB state during Exception
Next Article Cortex M0 Returning from Interrupt
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

Influence Factors That Affect Interrupt Latency

Interrupt latency refers to the time it takes for an…

10 Min Read

Arm Cortex M4 Lockup

The Arm Cortex-M4 is a popular 32-bit processor designed for…

8 Min Read

What is the difference between firmware and bootloader?

Firmware and bootloader are two important software components in many…

9 Min Read

Best practices for Cortex-M1 MMI generation in Xilinx FPGAs

Generating the Memory Mapped Interface (MMI) for a Cortex-M1 processor…

4 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account