Event Recorder and Component Viewer  Version 1.4.0
MDK Debugger Views for Status and Event Information
 All Files Functions Macros Groups Pages
Using Event Statistics

The following steps enable the MDK debugger views for Event Statistics on timing, number of calls, and current consumption.

To use Event Statistics in the application code:

  1. Follow the first two steps in Using Event Recorder.
  2. Annotate the C source with Event Execution Statistics.

Event Execution Statistics functions may be placed throughout the application source code to measure execution performance between corresponding start and stop events:

  • EventStartG (slot) or EventStartGv (slot, val1, val2) functions define the start point of an execution slot.
  • EventStopG (slot) or EventStopGv (slot, val1, val2) functions define the stop point of an execution slot.

The Event Statistics window shows collected data about execution time, number of calls, and (when using ULINKplus) the current consumption for each execution slot.

For the minimum and maximum time or current consumption it also shows for start and stop events the:

  • C source file name and line number of event calls via EventStartG (slot) or EventStopG (slot).
  • Integer values val1 and val2 of event calls via EventStartGv (slot, val1, val2) or EventStopGv (slot, val1, val2).

Each execution slot is identified by the function name group letter G = {A, B, C, D} and a slot number (0 to 15). Event filtering may be used to control the recording of each group. A call to EventStopG or EventStopGv with slot=15 stops measurement for all slots in a group and may be used at global exits of an execution block.

The following code is from the SCVD Event Statistics example project that is part of the Keil::ARM_Compiler pack:

Code example

#define TABLE_SIZE 1000
float sin_table[TABLE_SIZE];
// Calculate table with sine values
void CalcSinTable (void) {
unsigned int i, max_i;
float f = 0.0;
max_i = TABLE_SIZE - (rand () % 500);
EventStartAv (15, max_i, 0); // Start group A, slot 15, passing the max_i variable
for (i = 0; i < max_i; i++) {
if (i == 200) {
EventStartAv (0, max_i, 0); // Start group A, slot 0, passing the max_i variable
}
sin_table[i] = sinf(f);
f = f + (3.141592 / TABLE_SIZE);
if (i == 800) { // Measure 800 table entries
EventStopA (0); // Stop group A, slot 0
}
}
EventStopA (15); // Stop group A, slot 15 (stops also slots 0..14)
}
...
int main (void) {
SystemCoreClockUpdate(); // System Initialization
EventRecorderInitialize(EventRecordAll, 1U); // Initialize and start Event Recorder
EventStartC (0); // start measurement event group C, slot 0
for (j = 0; j < 1000; j++) {
CalcSinTable (); // calculate table with sinus values
EventStartB(0); // start group B, slot 0
MaxSqrtSum = rand () / 65536; // limit for sqrt calculation
num = FindSqrtSum ((float) MaxSqrtSum); // return number of sqrt operations
EventStopBv(0, MaxSqrtSum, num); // stop group B, slot 0, output values: MaxSqrtSum, num
}
EventStopC(0); // stop measurement event group C, slot 0
for (;;) {}
}

Build and run the example project which uses the ┬ÁVision simulator (available in all versions of MDK). In a debug session, Event Recorder, displays the following output:

er_with_statistics_annotated.png
Event Recorder with Start/Stop events and values

The Event Statistics window shows the statistical data about the code execution:

es_start_stop_wo_energy_annotated.png
Event Statistics

For more information on the usage of the functions, refer to the Event Recorder API.

Display current consumption

Using a ULINKplus debug adapter, you can also record and analyze the energy that has been consumed in each execution slot. Using the above example on a hardware target with a ULINKplus, you get the following displays in the Event Statistics window (the Event Recorder window does not change):

es_start_stop_w_energy.png
Event Statistics displaying the energy consumption