Event Recorder  Version 1.0.0
MDK Debugger Views for Status and Event Information
 All Files Functions Macros Groups Pages
Using Event Recorder

The following steps enable the MDK debugger views for static information and dynamic events.

For User Code:

  1. Add the Event Recorder to the project.
  2. Add Event Annotations in the C source to be able to stream dynamic event information.
  3. Create an SCVD file to Format Event Information that matches with application code.

For MDK Middleware and Keil RTX5:

The software packs for MDK Middleware and CMSIS already contain the *.SCVD files and the related event annotations in the C source code.

  1. Enable Event Recorder to the project.
  2. Select the required software component variant to enable event information.

Enable Event Recorder

To use the Event Recorder in an application, you need to:

  • Select the software component Compiler:Event Recorder using the RTE management dialog.
    SelEventRecorder.png
  • Include the EventRecorder.h header file and add the event recorder initialization function to the source code:
    :
    #include "EventRecorder.h" // Keil::Compiler:Event Messaging
    :
    int main (void) {
    :
    HAL_Init(); // configure hardware abstraction layer
    SystemClock_Config(); // configure system clock
    MemoryBus_Config(); // configure external memory bus
    EventRecorderInitialize (EventRecordAll, 1); // initialize and start Event Recorder
    :
    // other application code
    }
Note
By default, the Event Recorder is using the DWT Cycle Counter as a time reference. This is not available on all targets. Change the configuration to use an alternative timer instead.

Event Annotations

To to stream dynamic event information, insert calls to the Event Data Recording functions on relevant code locations:

These Event Data Recording functions receive as first parameter an id event identifier used for filtering and displaying. The macro EventID may be used to compose id values to include level and component numbers.

Example:

#include "EventRecorder.h" // Keil::Compiler:Event Messaging
int some_error = 0; // error flag
char string[10] = "MyTest"; // some test string
void MyFunction (int parameter) {
EventRecord2 (1+EventLevelAPI, parameter, 0); // Event at Start
;
if (some_error) {
EventRecord2 (2+EventLevelError, 0, 0); // Event at Error
return;
}
EventRecordData (3+EventLevelOp, string, sizeof(string)); // Event at Finish
return;
}
int main (void) {
EventRecorderInitialize (EventRecordAll, 1); // initialize and start Event Recorder
MyFunction (0x10);
some_error = 1; // set error flag
MyFunction (0x60);
}

When executing this example in the µVision debugger, use the menu command View - Analysis Windows - Event Recorder to open the Event Recorder window. This should show the following output:

EventOutput1.png
Output shown in Event Recorder window

Format Event Information

You may create an *.SCVD (Software Component View Description) file to format the event output so that matches the application. The event output is created using the /component_viewer/events element.

SCVD file example

<?xml version="1.0" encoding="utf-8"?>
<component_viewer schemaVersion="0.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="Component_Viewer.xsd">
<component name="MyExample" version="1.0.0"/> <!-- name and version of the component -->
<events>
<group name="My Events Group">
<component name="MyApp" brief="My Application" No="0x00" prefix="EvrNetMM_" info="Network - System - Dynamic Memory Management"/>
</group>
<event id="1" level="API" property="MyFunction" value="parameter=%x[val1]" info="Event on start of MyFunction" />
<event id="2" level="Error" property="MyFunctionError" info="Event on error in MyFunction" />
<event id="3" level="Op" property="MyFunctionProcess" value="string=%t[val1]" info="Event on operation in MyFunction" />
</events>
</component_viewer>

In the µVision debugger, this *.SCVD file is specified in the dialog Options for Target -> Debug -> Manage Component Viewer Description Files. Click on Add Component Viewer Description File and add the related .SCVD file.

Manage_SCVD_Files.png
Manage *.SCVD files

The Event Recorder displays the events as shown below.

EventOutput2.png
Event Recorder output formatted with *.SCVD file

The described groups and events also show up in the filter dialog.

EventRecorderFilter.png
Event Recorder Filter dialog

Software Component Variants

The software packs for MDK Middleware and CMSIS already contain SCVD files that match the related event annotations in the C source code. However, you need to select the right component Variant. For MDK Middleware, you need to select the Debug variants, whereas for Keil RTX5, you need to add the Source variant.

The example below enables event recording for the MDK-Middleware File System component:

SelSWComp.png

Redirecting printf output

The Event Recorder can be used to retarget printf output. This is especially interesting for targets without ITM, such as Cortex-M0/M0+/M23. Steps to enable this:

  1. In the Manage Run-Time Environment window, set the component Compiler:I/O:STDOUT to use Variant EVR.
  2. Select the component Compiler:Event Recorder or use the Resolve button.
  3. In the user code, include EventRecorder.h and call the EventRecorderInitialize() function in main().

Refer to the Compiler component example.