This example project shows how to use start/stop events with the Event Recorder.
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
#include "EventRecorder.h"
#include <math.h>
#include <stdio.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();
printf ("Started\n");
for (j = 0; j < 10000; j++) {
CalcSinTable ();
MaxSqrtSum = rand () / 65536;
num = FindSqrtSum ((float) MaxSqrtSum);
}
while (1) {
__NOP();
}
}
Build and run
This example project does not require an IDE and can be built using the CMSIS-Toolbox.
Clone this repository or download it as a ZIP file onto your computer. Follow the instructions in the README.md
file to build and run the project. Use the eventlist application to analyze the outcomes.