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

cross mob
Not applicable
Hello everyone,

I'm an electronics student working on my first ARM project with a XMC4200 hexagon board. I use keil MDK5 as an IDE.
I only have experience with the XC88 series programming in assambler so arm and Keil are completely new for me.
It took me a while to get started but now i'm able to setup the board and control some basic I/O.
Now i want to have some debug feedback from my board using a printf function.
From school out, i was only able to use the CMSIS library(so no dave generated code).
So i followed this link: link
and added this to my code. On the bottom of the page it goes about the redirect file.
I understand what this file is doing but i'm unable to get it working on my system.
When i go to the debug viewer in Keil, nothing is showing up.
Since i'm unable to find any tutorials or examples with the CMSIS library and a XMC microcontroller, i hope somebody on this forum could help me solve this issue.
Thank you in advance!
5 Replies
Not applicable
Hello everyone,

How sad, no reaction on this topic?
Is there any other more populated forum to ask my question on?
Not applicable
You're using Keil, and most people here are using Dave. We could tell you how to get printf working on Dave, but that's not what you need. Your question is pretty Keil specific; you might have better luck posting in the Keil forums.
Not applicable
As keil is way too expensive for me and i don't have enough time to find another ide. i started working with Dave4. I tried to get printf/xmc_debug working on my hexagon kit and it's not working. i followed this thread: https://www.infineonforums.com/threads/3489-DAVE-TIP-of-the-day-Semihosting-in-DAVEv4?
I'm unable to find any other info/examples on how to get this working.
What would be the difference between xmc_debug() and printf()?
I hope you guys can help me out now. thank you all.
Not applicable
Yep, Keil isn't cheap.

printf() uses a function called _write() which you need to provide. So printf will output to anything - you get to say where it goes. The link you mentioned uses semihosting. But if you have a USIC module setup as a UART, you can just printf out a UART port, by having _write() put data out your USIC port. As an example.

int _write(int file, uint8_t *buf, int nbytes)
this should return nbytes. Accept an pointer to an array of bytes, and the number of bytes to output.

For input you can use scanf. It ends up calling a function called _read, which you need to implement (eg to read received characters from a USIC module).
int _read(int file, uint8_t *buf, int nbytes)
It's given a pointer to an array of bytes, and the maximum number of bytes it wants. It returns the actual number of bytes its received (would be zero if nothing's been received), up to a max of nbytes.
Not applicable
Thank you for your input.
There are still a lot of things unclear to me.
In the reference manual for the XMC4200 hexagon kit says: the kit is designed to use SWO debugging.
So i guess this is not the same as UART?
Could you explain me how to setup swo without using dave apps? (i'm unable to open the dave app info so i don't want to use them)(i want to use the easy project to start with)
From what i understand, the int_write function you are telling about is necessary to get printf to work?
Will i be able to see the printf output in my dave console or do i need another application ( teraterm?)
In the examples from infeneon the XMC_Debug() function is used, what is this and how can i see the output of this? Is is similar to printf?
Thank you for the support!