Note
- The following steps explain how to enable views for static information and dynamic events in the µVision debugger. Other tools might use different ways to accomplish this.
For User Code:
For Pre-annotated Software Components:
The software packs for MDK-Middleware, CMSIS, CMSIS-FreeRTOS already contain the relevant *.SCVD files and the related event annotations in the C source code.
To use the Event Recorder in an application, you need to:
Note
- By default, the Event Recorder uses the DWT Cycle Counter as a time stamp source. This is not available on Cortex-M0/M0+/M23. Change the configuration to use an alternative timer instead.
- For Keil RTX5 (version 5.4.0 and above), no call to EventRecorderInitialize is required. Instead enable Event Recorder Configuration - Global Initialization in the RTX_Config.h file. Refer to the CMSIS-RTX Event Recorder Configuration for more information.
For uninterrupted recording of program resets, the RAM for the Event Recorder component should be placed to a memory region that is not cleared (or initialized) by a system restart (reset).
To setup this uninitialized RAM, use either Create memory region using linker script or Create memory region using µVision procedure.
Notes
- Make sure that you use normal, non-cacheable, and non-shareable memory for Event Recorder data.
The memory required for the Event Recorder data is calculated with the formula:
In this example we configure 0x800
bytes (as it is easier) which can hold more than 64 records.
If the linker script does not contain provisions for uninitialized memory section then, for respective toolchain, add the necessary section like described below:
Arm Compiler
For the Arm Compiler toolchain add the following code snippet to the linker script (.sct file), in the part specifying RAM sections (usually before Heap section):
Notes
- <start_address> is the physical address in RAM where the section will start
- 0x800 is the size of the section, adjust that as necessary
GCC
For the GCC toolchain add the following code snippet to the linker script (.ld file), in the part specifying RAM sections (usually before Heap section):
Note
- The code snippet above expects defined RAM memory region, if RAM region is not defined then adapt the script accordingly.
To setup this uninitialized RAM in the µVision, follow the steps below:
Note
- If the Event Recorder data buffer is not in uninitialized memory, the Command window of the debugger displays:
Warning: Event Recorder not located in uninitialized memory!".- Knowledgebase article 4012 explains how to create custom memory areas in Keil uVision.
- If your RAM is not big enough to separate the Event Recorder area from the Flash programming area, make sure that you enable "Reset and Run" for the Download Function:
- If this still produces broken Event Recorder records after a reset, a power-cycle of the target system will help.
To avoid display problems in System Analyzer, set the Time Stamp Clock Frequency [Hz] to the initially expected value:
The Event Recorder timer is a 32-bit counter that can overflow. To avoid overflow problems, send a "heartbeat" event within the limits of this 32-bit counter.
Calculation Example
Assuming that your application is running at 168 MHz, you can calculate the time between two heartbeats like the following:
So you need to generate an event every 25 s. This can be an event with an event ID that you don't need and thus filter from the display in Event Recorder or an event that you use to check if your application is still running.
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:
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:
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
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.
The Event Recorder displays the events as shown below.
The described groups and events also show up in the filter dialog.
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:
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:
EventRecorderInitialize()
function in main()
.Also see CMSIS-Compiler documentation for addition details about printf redirecting.
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:
Semihosting is a mechanism that enables code running on an Arm target to communicate and use the input/output facilities on a host computer that is running a debugger.
Examples of these facilities include keyboard input, screen output, and disk I/O. For example, you can use this mechanism to enable functions in the C library, such as printf
and scanf
, to use the screen and keyboard of the host instead of having a screen and keyboard on the target system.
With the Event Recorder, you can use semihosting with models to write the events into a file on your PC. This works with Arm Fast Models, Arm Fixed Virtual Platforms, and Arm Virtual Hardware alike.
The file that is written is called EventRecorder.log
and is a binary file that is available in the root directory of your project. Use eventlist Utility to read and decode the binary data.
Note
- Your model needs to be configured for semihosting (refer to the documentation of your modeling technology on how to do that).
- You can specify a different name for the log file by specifying a define called
EVENT_LOG_FILENAME
.- In µVision, once you start a new debug session, the log file will be overwritten. While in debug, new messages will be appended to the currently open log file.
- In µVision, the semihosting variant will not work with real target hardware. Instead, program execution will hit a breakpoint and stop there.
- In µVision, you can still use the Event Recorder window in µVision to see the events coming in while the file is written to the hard drive of your PC.