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];
void CalcSinTable (void) {
unsigned int i, max_i;
float f = 0.0;
max_i = TABLE_SIZE - (rand () % 500);
for (i = 0; i < max_i; i++) {
if (i == 200) {
}
sin_table[i] = sinf(f);
f = f + (3.141592 / TABLE_SIZE);
if (i == 800) {
}
}
}
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();
for (j = 0; j < 1000; j++) {
CalcSinTable ();
MaxSqrtSum = rand () / 65536;
num = FindSqrtSum ((float) MaxSqrtSum);
}
for (;;) {}
}
Build and run
- Open the project "SCVD Event Statistic" from Pack Installer (search for uVision Simulator in the Boards tab).
- Compile and run the application.
- 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