I have created a project in Microvision 5 for an ARM Cortex-M0 (ARMCM0), and enabled the Simulator. I pull up the Debug (printf) Viewer and run the following code
#include <stdio.h> main(void) { printf("Hello world\n"); }
but no output appears in the Debug window. The code is definitely running to completion (I added additional statements to check). I am running an Evaluation copy of Microvision V5 17.0.0.
Am I missing some checkbox or option to redirect output in the Simulator?
You wonder about "redirect output in the Simulator".
But long before you worry about that, you should spend some time trying to figure out what "console" your hardware has. What is printf() actually expected to do?
After you have considered that, you could look at the documentation how to direct printf() to a serial port of the processor. Then you could ponder how to let the debugger capture the serial data of that simulated serial port.
The above is rather important since embedded devices aren't PC machines - there are no pre-defined "standard out" device the debugger can directly capture to pick up printf() output.
Another thing - your program really shouldn't exit main(). This is also one of the differences from a PC - your program will not exit back to a command line prompt or a GUI.
Thanks for your reply, but I guess what I am asking is are there any User Templates, etc. for the M0 that will redirect a printf to the display that Keil labels "printf"? I would be surprised if they expect users to write driver/register level code just to get their debug window to work. There is almost certainly a package available that does this - surely I'm not the first to try to use the debug window?
I'm not sure if this is exactly the correct answer but you must get my drift
if ( value > 28000 ) value = 28000; else if (value < 0) value = 0;
It looks like you are using MDK version 5 with packs.
Are you using the Keil::ARM_Compiler Pack - it is used to redirect output
See
file:///C:/Keil_v5/ARM/Pack/Keil/ARM_Compiler/1.0.0/Doc/html/index.html
In particular here is an example Debug (printf) viewer