I/O Retargeting  Version 1.2.0
User Code Templates for I/O Retargeting using ARM Compiler
 All Files Macros Pages
Retarget STDOUT via Event Recorder

Copy the SCVD printf Redirect Example application for the ┬ÁVision Simulator to your PC using Pack Installer. This simple application is already set to redirect printf output on an Arm Cortex-M0 to the Event Recorder.

To retarget STDOUT to the Event Recorder in a user application, these steps are required:

  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():
    #include "cmsis_os2.h" // ARM::CMSIS:RTOS2:Keil RTX5
    #include "stdio.h"
    #include "EventRecorder.h" // Keil.ARM Compiler::Compiler:Event Recorder
    typedef struct {
    uint32_t hi;
    uint32_t low;
    } MyType;
    MyType mysymbol;
    int main(void) {
    int i;
    EventRecorderInitialize(EventRecordAll, 1);
    while (1) {
    for( i=0; i<=30; i++ ) {
    printf("The value of i is %d\n", i);
    mysymbol.hi = i*i;
    mysymbol.low = i;
  4. (For simulation only!) Open the target options dialog and add a Debug.ini file to simulate the DWT Cycle Counter:
    MAP 0xE0001000, 0xE0001007 READ WRITE
    signal void DWT_CYCCNT (void) {
    while (1) {
    _WWORD(0xE0001004, states);

Build and run the project. Open the Debug (printf) Viewer window using View - Serial Windows - Debug (printf) Viewer. The printf output will be shown here:


If you are using the Event Recorder window at the same time, you will notice that it also shows the printf output, just with hexadecimal display:

  • If your output is garbled, you might want to consider increasing the buffer size for the Event Recorder.
  • The Event Recorder window will display missed events to notify you about buffer size problems.