Introduction to power debugging
Reasons for using power debugging
Long battery lifetime is a very important factor for many embedded systems in almost any market segment—medical, consumer electronics, home automation, etc. The power consumption in these systems does not only depend on the hardware design, but also on how the hardware is used. The system software controls how it is used.
For examples of when power debugging can be useful, see Optimizing your source code for power consumption.
Briefly about power debugging
Power debugging is based on the ability to sample the power consumption—more precisely, the power being consumed by the CPU and the peripheral units—and correlate each sample with the application’s instruction sequence and hence with the source code and various events in the program execution.
Traditionally, the main software design goal has been to use as little memory as possible. However, by correlating your application’s power consumption with its source code you can gain insight into how the software affects the power consumption, and thus how it can be minimized.
Measuring power consumption
The debug probe measures the voltage drop across a small resistor in series with the supply power to the device. The voltage drop is measured by a differential amplifier and then sampled by an AD converter.
Power debugging using C-SPY
C-SPY provides an interface for configuring your power debugging and a set of windows for viewing the power values:
The Power Log Setup window is where you can specify a threshold and an action to be executed when the threshold is reached. This means that you can enable or disable the power measurement or you can stop the application’s execution and determine the cause of unexpected power values.
The Power Log window displays all logged power values. This window can be used for finding peaks in the power logging and because the values are correlated with the executed code, you can double-click on a value in the Power Log window to get the corresponding code. The precision depends on the frequency of the samples, but there is a good chance that you find the source code sequence that caused the peak.
The Power graph in the Timeline window displays power values on a time scale. This provides a convenient way of viewing the power consumption in relation to the other information displayed in the window. The Timeline window is correlated to both the Power Log window, the source code window, and the Disassembly window, which means you are just a double-click away from the source code that corresponds to the values you see on the timeline.
The Function Profiler window combines the function profiling with the power logging to display the power consumption per function—power profiling. You will get a list of values per function and also the average values together with max and min values. Thus, you will find the regions in the application that you should focus when optimizing for power consumption.
Requirements and restrictions for power debugging
To use the features in C-SPY for power debugging, you need one of these:
AJ-Link/J-Link Ultra debug probe and a J-Link RX adapter. Target boards with built-in J-Link do not support power debugging.
An E2 emulator which must be powering the target board. E2 Lite, EZ-CUBE2, and E2 on-board do not support power debugging.
Important! Power measurement for the E2 emulator is based on collecting pairs of current measurements and timestamps after the application execution stops. This slows down debugging performance considerably, so make sure that power logging is enabled for E2 only when you are actively using the feature. It also means that if the IDE seems to stall now and then, it might be because of this performance reduction.