Event Recorder and Component Viewer  Version 1.5.1
MDK Debugger Views for Status and Event Information
SCVD Event Statistics

This example project shows how to use start/stop events with the Event Recorder. For further details refer to Using Event Statistics.

The start/stop events allow to measure execution times with different slots (0 - 15) in four different groups (A - D). The call to 'EventStart' starts a timer slot; the call to 'EventStop' stops the related timer. A call to EventStop with slot 15 stops the timers of all slots in the specific group.

This demo application does some time consuming calculations that are recorded. It runs in simulation and does not require any hardware to be present.

main.c File

#include "RTE_Components.h"
#include CMSIS_device_header
#ifndef RTE_Compiler_EventRecorder
#warning This example requires the Event Recorder component
#endif
#include "EventRecorder.h"
#include <math.h>
#include <stdlib.h>
#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)
}
// Return number of sqrt operations to exceed sum
unsigned int FindSqrtSum (float max_sum) {
unsigned int i;
float sqrt_sum;
sqrt_sum = 0.0;
for (i = 0; i < 10000; i++) {
sqrt_sum += sqrtf((float) i);
if (sqrt_sum > max_sum) {
return (i);
}
}
return (i);
}
unsigned int j, num, MaxSqrtSum;
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

  1. Open the project "SCVD Event Statistic" from Pack Installer (search for uVision Simulator in the Boards tab).
  2. Compile and run the application.
  3. Open the windows View - Analysis Windows - Event Recorder and View - Analysis Windows - Event Statistics to verify the output.
Event Recorder with Start/Stop events and values


Event Statistics