printf in DAVE4.4.2

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User15058
Level 1
Level 1
Hello Guys,
I am currently using Dave 4.4.2. and working with XMC4500 hexagon kit. I have browsed many threads regarding using SWO console
for printing debug messages.I have read and tried everything related to turning on the print functionality. But unfortunately, nothing
seems to work out.

Is anybody else facing the same problem? If not, then could anybody guide me on how to configure it correclty ?
I really beg for some help.
0 Likes
11 Replies
lock attach
Attachments are accessible only for community members.
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

See attached project.
Follow these instructions:
1. Define XMC_DEBUG_ENABLE (which uses printf)
3177.attach
2. Linker options, enable semihosting by adding --specs=rdimon.specs in Other flags text entry
3178.attach
3. In the debugger configuration, enable semihosting and click on GDB client
3179.attach
4. After the debugger is launched, switch to the Semihosting and SSW view
3180.attach

Regards,
Jesus
0 Likes
User15058
Level 1
Level 1
Thanks jferreira,

its working now.
0 Likes
User16238
Level 1
Level 1
Hi Jesus

I followed your steps above but it still doesn't working.

I get the following error:
Starting target CPU...
WARNING: Semihosting command SYS_FLEN failed. Handle is 0.
WARNING: Semihosting command SYS_WRITE failed. Handle is 0.


Unfortunatelly your example did also not help as the importent part (the "initialise_monitor_handles" function) seems to be missing.

Do you have an idea what I could try?
0 Likes
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

You need to use in the linker settings, -specs=rdimon.specs

Regards,
Jesus
0 Likes
User7795
Level 4
Level 4
Hi Infineon,

it runs fine on C source files, but I have no success on C++ source files. There is no code generated of fct initialise_monitor_handles.

My source compiles without error:

#include
extern "C" void initialise_monitor_handles(void);

int main(void) {
void initialise_monitor_handles();
while (1) {
XMC_DEBUG("Hello\n");
}
return 0;
}

Settings:
C++ compiler and C compiler preprocesser XMC_DEBUG_ENABLE added
C++ linker --specs=rdimon.specs at Other flags added

Unfortunately no source of fct initialise_monitor_handles() available.

Please what's wrong?

Best Regards
Wolfgang
0 Likes
User7795
Level 4
Level 4
Oh, now I see the mistake, I am guilty, not C++, there is a 'void' too much in the code.
'void initialise_monitor_handles();' that's not a fct call, but a fct declaration.

This C++ code runs fine:

#include
extern "C" void initialise_monitor_handles(void);

int main(void) {
initialise_monitor_handles();
XMC_DEBUG("Hello\n");
return 0;
}

Best Regards
Wolfgang
0 Likes
User18026
Level 1
Level 1
The solution mentioned is correct.

1. enable the XMC_DEBUG flag
2. add the 'extern void initialise_monitor_handles(void);' declaration in the file where calling XMC_DEBUG
3. Call the initialise_monitor_handles() function before calling the XMC_DEBUG function,
4. In the debugger settings, enable Semihosting over GDB under 'Startup' tab.
5. Debug the program. The output should be visible under the 'Semihosting and SWV' thread.

For some older versions of DAVE some additional preprocessor symbols have been added. I did not add these for DAVE 4.4.2.
0 Likes
User7795
Level 4
Level 4
Hi,

there is a trap, which costed me 2 hours:
Don't forget the new line character ("\n") at the end of the string. Otherwise you will see nothing on your semihosting window.

The new line character must be part of the string:
XMC_DEBUG ("Hello\n");
This version also shows nothing on the screen:
XMC_DEBUG ("Hello");
XMC_DEBUG ("\n");

When using sprintf to display numeric values, this code runs (prints value of x in decimal number format):

char buffer[20];
sprintf (buffer, "%d \n", x);
XMC_DEBUG (buffer);
0 Likes
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
0 Likes
User7795
Level 4
Level 4
Hi Jesus,

you recommend to use
fprintf (stderr, "Text to display");
instead of XMC_DEBUG?

A first test was not successful, only the first character (the "T") was displayed.

Best Regards,
Wolfgang
0 Likes
Anis399
Level 1
Level 1
First like received First reply posted Welcome!

I hope this is helpful, I just recorded this by following the steps in this thread. 

https://www.youtube.com/watch?v=-iDKpxj51pI