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 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. Place Event Recorder in uninitialized memory to avoid overwriting the entries on program reset.
  3. Add Event Annotations in the C source to be able to stream dynamic event information.
  4. 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.
  • 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
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.

Place Event Recorder in uninitialized memory

To be able to run without interruptions from program reset, the Event Recorder component has to be placed inside a memory region that is not initialized during reset. This can be either achieved using a linker script, or from within uVision using the Options for Target dialog:

  • Prepare a RAM memory region that can be left uninitialized. For that, open the Options for Target dialog or press Alt+F7. On the Target tab, locate your read/write memory. For example, you might have an IRAM1 starting at 0x20000000 with a size of 0x20000.
  • To calculate the required memory for the Event Recorder, use this formula: 128 + 36 + 16 x Number_of_Records. The number of records corresponds to the #define EVENT_RECORD_COUNT in the EventRecorderConf.h file. The default number is 16. This equates to a total required memory of 1188 bytes. Let's continue with 2048 bytes for easier calculation which translates to 0x800.
  • In the memory layout dialog, reduce the size of IRAM1 by 0x800 and create an IRAM2 starting at 0x2001F800 with a size of 0x800. Enable the NoInit for this region.
  • Click OK to close the dialog.
  • Right-click EventRecorder.c in the Project window and select Options for Component Class 'Compiler'. A new window opens.
  • Go to the Memory tab and assign all memory locations to this new IRAM2 region:

  • (Re-)build your application. Your Event recorder component will now be placed in uninitialized memory. You can check the settings by opening the automatically generated scatter file:
    ; *************************************************************
    ; *** Scatter-Loading Description File generated by uVision ***
    ; *************************************************************
    LR_IROM1 0x00000000 0x00040000 { ; load region size_region
    ER_IROM1 0x00000000 0x00040000 { ; load address = execution address
    .o (RESET, +First)
    .ANY (+RO)
    RW_IRAM1 0x20000000 0x0001F800 { ; RW data
    .ANY (+RW +ZI)
    RW_IRAM2 0x2001F800 UNINIT 0x00000800 {
    EventRecorder.o (+ZI)
If you do not place your Event Recorder component in uninitialized memory, you will see a warning in the Command window of the uVision debugger: "Warning: Event Recorder not located in uninitialized memory!".

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.


#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
EventRecordData (3+EventLevelOp, string, sizeof(string)); // Event at Finish
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:

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.

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 -->
<group name="My Events Group">
<component name="MyApp" brief="My Application" no="0x00" prefix="EvrNetMM_" info="Network - System - Dynamic Memory Management"/>
<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" />

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

The Event Recorder displays the events as shown below.

Event Recorder output formatted with *.SCVD file

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

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:


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 example Retarget STDOUT via Event Recorder in "I/O Retargeting".

Event filtering

Filtering for events reduces the amount of data transmitted from the target to the debugger. To filter for events, use the button Configure Target Event Recording:


A new window opens up that lets you filter for events that you are interested in:

Filtering events