I'm trying to use printf() on uVision4 in Simulation mode. The code runs or steps fine in the debugger but the "Debug (printf) Viewer" doesn't show anything. Was I wrong to assume that it should "just work" whenever the configured device has a S*OUT VTREG?
The manual doesn't explain much, which led me to believe it should work. I'm mostly looking at a NXP LPC1769 but really any Cortex-M3 would do for now. Did s0time = 0, and here's the start of ASSIGN and excerpt from DIR VTREG resp:
assign WIN: <S0IN >S0OUT WIN2: <S1IN >S1OUT WIN3: <NUL >NUL COM1: <NUL >NUL S0IN: ushort, value = 0xFFFF S0OUT: ushort, value = 0x0000 S0TIME: uchar, value = 0x00 S0BAUD: ulong, value = 0x00002580 S1IN: ushort, value = 0xFFFF S1OUT: ushort, value = 0x0000 S1TIME: uchar, value = 0x00 S1BAUD: ulong, value = 0x00002580
Also, the value of S0OUT in the watch window doesn't change; should I expect it to show the transmitted characters?
Cheers
Hi,
you should use a simulated UART or the ITM printf, because there is no semihosted or other direct channel.
It is easy, because you are using a Cortex-M3. Have a look at the CMSIS, core_cm3.h, it gets included by the device header file.
You can copy this example to your code and have printf running. This just works by overwriting fputc-function.
If you want to implement a proper retargeting, have a look into the examples which contain a 'retarget.c'
#include <stdio.h> #include "LPC17xx.h" int fputc(int c, FILE *f) { return(ITM_SendChar(c)); } int main (void) { ... printf("Hello, World"); while(1);
. BR, /th.
The 'assign' command just connects the virtual UART channels from the simulator with the UART channels on your PC.