Event Recorder (EVR) provides an API (function calls) for event annotations in the application code or software component libraries. It uses CoreSight DAP to output data from the target (memory reads/writes). This means any debug adapter can be used. MDK-Middleware , Keil RTX5 , and CMSIS-FreeRTOS are already annotated. EVR requires a certain amount of system RAM.
μVision provides a simple printf
utility using the Event Recorder. It does not require a UART and it is much faster. Text is displayed in the
Debug (printf) Viewer
window.
retarget_io.c
, EventRecorder.c
, and EventRecorderConf.h
will be added to your project under the Compiler group in the Project window:Blinky.c
(at line 7), choose Insert ‘#include file’, and select:
#include "EventRecorder.h"
main()
function (near line 39), just after SystemCoreClockUpdate();
, add these lines:
EventRecorderInitialize(EventRecordAll,1);
EventRecorderStart();
Now, create a global variable named counter
whose value will be printed on Debug (printf) Viewer window.
uint32_t counter = 0;
Delay(1000)
statement at line 46:
counter++;
if (counter > 0x0F) counter = 0;
#include "stdio.h"
if (counter > 0x0F…
), add:
printf("Hello %d\n", counter);
cpu0.semihosting-enable=1
In the
Command
window, you will see Warning: Event Recorder not located in uninitialized memory!
. This can be safely ignored for the purpose of this tutorial.
In general, it can be important to preserve the EVR data located in the target’s RAM in the event of a crash and/or reset. Creating and using non-initialized memory is implemented by modifying the scatter file. Knowledge base article KA003868 explains how to modify your project to do so.
With Event Recorder, you can also annotate your source code which can be displayed in various information windows.
while(1)
loop (around line 47):
EventRecord2(3, 44, counter);
EventRecord2(3, 44, counter);
event.printf
frames (stdout) are also displayed with the printf data in hexadecimal form.printf
with a 9600 baud/8 characters UART requires about 80,000 CPU cycles or about 8 msec. Using Event Recorder, it takes only ~500 CPU cycles. Event Recorder is 10 times faster than a UART running at highest speeds. Using an Event such as StartB(1)
with 8 bytes is even faster: only ~250 CPU cycles.It is possible to filter the window contents. Modify the information displayed in the Event Recorder window using the funnel icon which will open the Show Event Levels window. You can specify what elements are collected and displayed in the Event Recorder window.
You can save and recall the filter settings. In the Command window, execute:
ER SAVE path\filename
ER LOAD path\filename
You can add start and stop events to your source code to collect information about execution counts and times. If you are using a ULINKplus debug adapter, information can also include voltage, current, and total charge (Q) consumed. Individual and aggregate times are provided in the Event Statistics window. This information will be collected between the start and stop event tags including the execution of any exception handlers or program branches.
EventStartX(slot)
and EventStartX(slot, v1, v2).
EventStopX(slot)
and EventStopX(slot, v1, v2)
.
EventStartA(2);
EventStopA(2);
EventStartB(4,34, counter);
For correct timing information when working with real hardware, the core clock needs to be set up correctly.
The above is not required in simulation!
EventStartA(11);
EventStopA(11);
This provides a good method to determine timings relative to your source code. Event Statistics is easy to configure and interpret. You can create up to 64 start/stop events.