PEmicro Blog

NXP: Real-Time SWO Debug and Power Measurement Support in NXP's MCUXpresso

Dec 11, 2018

PEmicro's Multillink debug probes feature real-time SWO data capture as well as power consumption monitoring in NXP's MCUXpresso. SWO data capture includes high speed printf() output from running code, R/W accesses to memory and variables, interrupt execution, and more. The power consumption monitoring of the Multilink FX model runs up to 250KSamples/S with a current detection range of 1mA to over 200mA. 

Introduction

While MCUXpresso has many great real-time data features, this blog post will highlight the following four features : Power Measurement, SWO ITM Console, SWO Data capture, and Real-Time Expressions. Below is an overview of each debug view.

PEmicro's Real-Time Power Measurement: Tracks the current consumption of the device in real-time, in a scalable window. This allows the user to monitor changes in power consumption in real-time as the processor goes through different power modes, uses different peripherals, and runs different code segments.

SWO ITM Console:
  The SWO ITM mechanism allows running code to stream messages out of the processor's SWO pin via the printf() call in real-time. This streaming occurs at a high data rate without stopping the target processor and as such is less intrusive than traditional methods.The streamed data is captured by the Multilink and redirected to the SWO ITM console window for display.

SWO Data: In addition to streaming printf() data, the SWO pin can also stream real-time microcontroller events such as interrupts occurring and memory reads and writes of specific variables and registers. The SWO Data view allows the user to configure variables to be tracked such that any reads and writes to these variables are captured and streamed to the Multilink via the SWO pin. This view shows shows the real-time access which have occurred along with the timing of the different accesses.

PEmicro's Real-Time Expressions: Allows the user to monitor multiple variables and expressions  - all in real time as the code runs on the device. There’s no need to halt the device to gain valuable insight into the state of different peripheral registers and memory-mapped variables.

To turn on these views, use the MCUXpresso main menu to select : Window → Show View → Other. In the folder MCUXpresso IDE Trace category, select SWO ITM Console and SWO Data.  In the PEmicro category, select the Power Measurement and Real Time Expressions views.

Real-Time Power Measurement

To enable Power Measurement capture, an active debug session must already be in process. Click the Gear Icon on the title bar of the PEmicro "Power Measurement View". Select the frequency of data capture and check the Enable Box. After clicking OK, Power Recording is now active.

The next time the target MCU is run, real-time power measurement readings will be shown :

The user can start/stop power recording, zoom, export data, and more.

SWO ITM Console (Printf Data)

The SWO ITM Console will display messages which are streamed through the SWO pin and captured by the Multilink. There are two main configuration steps needed to leverage this feature. First, the project must be configured to re-direct the printf() statements to the SWO ITM peripheral. This is done at project creation time. Second, the Green "Play" button on the SWO ITM Console needs to be clicked during an active debug session. 

This will cause data collection of SWO printf information to occur on the next Resume :

The Multilink automatically measures the data communication rate on the SWO pin and adjusts to it automatically. This auto-detect sequence is done each time the processor is stopped in debug mode. If the running code changes the core frequency, a breakpoint should be set after the frequency change so the Multilink can adjust to the new SWO communications rate (which is a function of the core frequency).

SWO Data (Capturing Memory Accesses)

The SWO Data view allows the user to configure variables to be tracked such that any reads and writes to these variables are captured and streamed to the Multilink via the SWO pin. This view shows all of the real-time access which have occurred along with the timing of the different accesses.

For SWO data, there is a bit more setup.  The user needs to select the 'Eyeglasses+' symbol which will bring up a popup of Add datawatch items.  Simply enter the information of the different variables to be tracked. Up to four separate variables can be tracked simultaneously. In this example, we select that we wish to capture read and writes of the ledsOn and seconds variables. Once added, the user needs to select which watches data will be captured by checking the "Enable trace" boxes in the SWO Data window and then click the Green Arrow to set the program to start capture on Resume.

Upon resuming the application, the right side of the window will show the access which are occurring. Note that this happens in real-time; the microcontroller is not stopped when accesses occur (i.e. the is separate from data breakpoints).

The Multilink automatically measures the data communication rate on the SWO pin and adjusts to it automatically. This auto-detect sequence is done each time the processor is stopped in debug mode. If the running code changes the core frequency, a breakpoint should be set after the frequency change so the Multilink can adjust to the new SWO communications rate (which is a function of the core frequency).

Real Time Expressions

This view is similar to the standard Eclipse "Expressions" window with the exception that its contents will update in real-time without the device being halted in debug mode. Just add the appropriate variables to the Real Time Expressions windows and you will see them updating in real-time.

Below is a video of the real time expressions as the program is running where we can see the time and the ledsOn expression changing as the program is running.

Troubleshooting

If you are having trouble enabling the Power or SWO capabilities in MCUXpresso, please see the following topics.

Verify PEmicro Hardware Model supports Power Measurement and SWO Output

Minimum required hardware for each IDE feature

Real Time Power Measurement

  • Multilink Universal FX Rev C and later

SWO ITM Console and Data

  • Multilink ACP Rev. B and later
  • Multilink Universal Rev. D and later
  • Multilink Universal FX Rev C and later

Real Time Expressions

  • All Multilinks, Cyclones, and OpenSDA HW Platforms

Make sure the latest PEmicro Plug-in is Installed

The user should make sure their MCUXpresso IDE is at least version 10.3 and that the PEmicro Eclipse plugin has been updated to the latest version.  In the top bar of MCUXpresso click on Help → Install New Software. Choose the PEmicro eclipse update site : 

http://www.pemicro.com/eclipse/updates  

Expand the "PEmicro Software" category and select only the "GNU ARM PEmicro Interface Debugging support" box. Click the Next button and click through as necessary to install.

Make sure Debug Configuration enables SWO/Power

If power measurement or any of the SWO capabilities are not working, make sure the PEmicro GDB server is configured to provide SWO and Power information. Open up the current debug configuration. Select the Debugger tab and scroll to the bottom.  Make sure that Enable Streaming is selected and the Streaming Server port is set to 10224 as shown highlighted in yellow.


Tags related to this Blog Post

Multilink     Multilink FX     NXP     Debug