I've followed the steps here to copy the "printf_redirect" example project from the pack installer: www.keil.com/.../_retarget__examples_er.html
I left everything as is within the example project. When I rebuild the "CM0 Simulator" target, it succeeds but with 1 warning:
C:\Keil_v5\ARM\PACK\Keil\ARM_Compiler\1.6.0\Source\EventRecorder.c(660): warning: #1215-D: #warning directive: "Invalid Time Stamp Source selected in EventRecorderConf.h!"
When I start debug in the simulator, it runs the included debug.ini file as expected. But I only see values updating in the "My First Viewer" window, not the Event Recorder or Debug (printf) Viewer windows.
Does something need to be done for the compiler warning? Is there a step not listed at the URL above that I'm missing? I just expected this example project to work out of the box. My immediate goal is to simply run this example project and see output in the Debug (printf) Viewer, so that I may later adapt an existing project to similarly redirect I/O.
Keil uVision: version 5.23.0.0 Toolchain: MDK-ARM Standard Cortx-M only, version 5.23 Compiler/Assembler/etc: version 5.06 update 4 (build 422)
Thanks!
As written here http://www.keil.com/support/man/docs/uv4/uv4_db_dbg_evr_setup.htm , the default Time Stamp Source is the DWT Cycle Counter that is part of the CoreSight debug interface. This counter is not available in Cortex-M0 and Cortex-M0+.
This compiler warning tells you exactly what you should check
From my link: "This simple application is already set to redirect printf output on an ARM Cortex-M0 to the Event Recorder."
So that statement appears to be wrong, and modifying the project to use the non-default timestamp source is required? Then why does this project also include the debug.ini file with the simulated DWT Cycle Counter? Maybe it's just oversight, although the target is named "CM0 Simulator".
I'm trying to configure SysTick instead of the default DWT Cycle Counter.
Based on the http://www.keil.com/support/man/docs/uv4/uv4_db_dbg_evr_setup.htm link, I defined the following in the EventRecorderConf.h file:
//default #define EVENT_RECORD_COUNT 64U #define EVENT_TIMESTAMP_FREQ 0U //modified #define EVENT_TIMESTAMP_SOURCE 1 #define SYSTICK_CLOCK 1000000000 #define SYSTICK_PERIOD_US 1000
I also added "#include "cmsis_os2.h"" to the main.c file.
Now the linker error I get when compiling is:
.\Objects\MyFirstViewer.axf: Error: L6200E: Symbol SysTick_Handler multiply defined (by irq_cm0.o and eventrecorder.o).
What is the next step I'm missing to configure the SysTick option? I'm surprised there isn't a ready-to-go example for this option for CM0/+.
When I remove "#include "cmsis_os2.h"" from the main.c file, that fixes the previous linker error. So then I also tried adding to main.c:
#include "ARMCM0.h" #include "system_ARMCM0.h" //snip... SysTick_Config(SystemCoreClock / 1000);
But still nothing is output to the Event Recorder or Debug (printf) Viewer windows, with or without performing SysTick_Config.
After some digging, I found the SCVD Cortex-M0 SysTick example project, as described at: www.keil.com/.../scvd_CM0_SysTick.html
I tried running this project as is, both with and without the Compiler/IO/STDOUT/EVR component (retarget_io.c) included in the Run-Time Environment, but I still see no output in the Event Recorder or Debug (printf) Viewer windows.
It seems I'm stuck again, any ideas?
printf_redirect example
It should work out of the box. I have tried it with the latest MDK V5.26 which also includes ARM_Compiler pack V1.6.0 (includes EventRecorder). I see the expected values in Debug (printf) and Event Recorder Window. You should try it out with the latest MDK and updated example.
I also get the mentioned compiler waring (was introduces by the newer Event Recorder component) but you can ignore it since the simulator for Cortex-M0 is extended with a debug script to emulate DWT Cycle Counter.
Anyway you can change the Time Stamp Source to SysTick. Modify the EventRecorderConf.h:
#define EVENT_TIMESTAMP_SOURCE 1
Then the warning goes away and the example actually uses the SysTick rather than DWT.
It seems that you have an older example. Try out the updated example from latest ARM_Compiler pack 1.6.0.
SCVD Cortex-M0 SysTick example
Also that example should run out of the box. I have just tried the latest example from ARM_Compiler pack 1.6.0 and I see the expected events in the Event Recorder window. Note: Debug (printf) retargeting is not used in this example.
Thanks for the suggestion! I upgraded to MDK v5.26 and both projects now work.