energyAware Profiler – Online Help
The energyAware Profiler allows developers to quickly visualize the energy consumption in their applications and perform optimizations to reduce power consumption.
The energyAware Profiler uses the built-in PC sampling and IRQ event tracking in the EFM32™. Power is measured using the built-in AEM in the Gecko Development Kit or Starter Kit.
The profiler correlates the PC sampling with the current measurements from the kit and displays this information in the form of a graph. Using the debug information embedded in the object code, this correlation makes it possible to build an energy profile showing which functions are responsible for energy consumption.
Prerequisites for energyAware Profiler
Setting Up the energyAware Profiler
For the energyAware Profiler to work correctly it is necessary to do some modifications to the binary which will be profiled. The following steps are required:
1. Enabling Serial Wire Output
To use the energyAware Profiler it is necessary to setup the program for SWO output prior to using the energyAware Profiler. When starting the profiler, it will show a snippet of code called setupSWO(). Insert this function into your own program and call the function early in main.
Note: using the SWO functionality adds to the current consumption.
2. Enabling Debug Symbols in Object Files
The code must be compiled with debugging information enabled. Selecting the "Debug" mode will, in most IDEs, embed such information in the resulting ELF binary. If such information is not present the profiler will be unable to correlate the PC of the program to the source code.
Interrupt Service Routines and Trace
Serial Wire Output trace is only emitted if AUXHFRCO is running. This clock is usally disabled in EM2 and must be manually switched on. Normal IRSs will not enable AUXHFRCO when they are executed, so no PC sampling will be performed while the processor is in the ISR. To counter this you must:
- Set EMVREG to full in EMU->CTRL – this will provide power to AUXHFRCO while in EM2+
- Enable AUXHFRCO – this will allow trace functionality while in EM2+
Note: setting EMVREG to full will increase power consumption in EM2+ by about 200μa.
Using the energyAware Profiler
Flash the EFM32 with the Program to Profile
To use the energyAware Profiler, simply set up your project using the setupSWO() function introduced in the previous section. Compile and flash the EFM32 with the new program. This will activate the debug interface which will prevent the EFM32 from entering EM2. To solve this issue simply reset the EFM32 or the kit.
Set the Object File
Start the energyAware Profiler and select the object file in "File->Load Object File." This step is necessary for correlating PC samples with the source code.
Note: the DWARF debug information embedded in regular ELF object files uses absolute paths, so it is not possible to move source files after creating the object file.
Starting and Stopping the Sampler
The sampling can be started and stopped by using the controls in the toolbar. Clearing all data can be done by first pausing the sampling and then pressing the clear button.
AEM Current Graph
The AEM graph will be continuously updated while sampling is performed. By pausing sampling it is possible to scroll the view of the graph to any previous point. Checking the box "Annotate IRQ" will show IRQ events as coloured pins on the graph.
The graph can either be displayed as a logarithmic plot or a linear plot. Switching between the two views can be done by checking or unchecking the box in the toolbar. The logarithmic view can be further customized under "Options->Preferences..."
Examining a Point on the Graph
Clicking anywhere on the graph will display the corresponding source line in the "Code View" window, and update the status bar with the current consumption, voltage, PC, time and current IRQ for that specific point.
Examining a Section of the Graph
After selecting a point on the graph, a marker can be placed. Right click anywhere on the graph and select "Place Marker." To select a portion of the graph, pick a second point, right click, and select "Place Marker." The statusbar at the bottom of the program will display statistics regarding the interval such as length (in milliseconds), average current and energy used.
Right clicking on the graph a third time and selecting "Generate Profile" will pop up a small window showing the break-down of functions executed during that interval.
The energy profile is updated every 100 samples and is sorted by energy. This will let you see which functions contribute the most to the overall energy consumption.
Double clicking on a function lets you chose a color for that function. This color will be used when drawing the graph.
The code view displays the corresponding line of code for a given point on the graph. The colors used for syntax highlighting is configurable and can be set in "Options->Preferences..."
Loading and Saving Traces
The energyAware Profiler supports loading and saving traces to Comma Separated Values (CSV), which can be easily imported and exported to external programs such as Excel.
FAQ – Frequently Asked Questions
Q: The current consumption is never below 1 mA, even though my program enters Energy Mode 2 (EM2) or lower on many occasions.
A: This can happen if the EFM32 has entered debugging mode. When the EFM32 is in debugging mode it cannot enter EM2 or lower. To resolve this issue simply reset the EFM32.
Q: The current consumption is about 80 μA in EM2.
A: This happens on some kits with firmware version 1v3 or earlier. This is due to a bug in the debugger which leaves one of the debugging pins high against the internal pull-downs on the EFM32. Simply reset the kit to resolve this issue.
On kits with firmware later than 1v3, the kit will automatically fix this issue if all debugger connections are closed. (The profiler must be paused.)
Q: Sometimes the PC or IRQ number is clearly wrong.
A: This happens when the EFM32 quickly oscillates between sleep and active mode. The profiling functionality in the EFM32 is only active in Energy Mode 0 (EM0) and Energy Mode 1 (EM1). However, if the EFM32 goes to sleep while transmitting a packet, the packet can become corrupted. This problem can be alivieated by enabling the debug clock in EM2. Setting EMVREG in EMU->CTRL to full will enable the trace functionality at all times. However, doing so will increase the power consumption in EM2 by about 200 μA.
Q: I have selected an object file, but there is nothing shown when clicking on the graph.
A: This can have multiple causes. First, make sure that the object file contains debugging information. Second, the DWARF information used in ELF object files uses absolute paths. If you copy the binary from one machine to another this can result in the paths being wrong.
Q: Can I use the energyAware Profiler with my own PCB?
A: Yes. Use the "Debug Out" functionality of the DVK or STK to achieve this. The EFM32 on your design must be powered by VMCU on the debug connector on the DVK or STK. In addition, the serial wire output pin must be connected to the serial wire output pin on the "Debug Out" connector of the DVK/STK.
DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no obligation to support this Software. Silicon Labs is providing the Software "AS IS", with no express or implied warranties of any kind, including, but not limited to, any implied warranties of merchantability or fitness for any particular purpose or warranties against infringement of any proprietary rights of a third party.
Silicon Labs will not be liable for any consequential, incidental, or special damages, or any other relief, or for any claim by any third party, arising from your use of this Software.
The energyAware Profiler uses a number of third party LGPL licensed libraries: