How do I make "Debugger Console" work with printf?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I make "Debugger Console" work with printf?

Jump to solution
5,219 Views
quevedo
Contributor V

Hello,

 

I am using CW10.4, and a FRDM-KL25 board. I would like to use the "Debugger Console" support to write out some variable values in a console window. I ahev created a project, using the bareboard project wizard and selecting "Debugger Console" on "I/O Support". However, when I try to use printf(), nothing is printed out at the console window on debug perspective. Probably something else must be set up.

 

Any ideas?

 

Thanks in advance

Labels (1)
0 Kudos
Reply
1 Solution
1,849 Views
BlackNight
NXP Employee
NXP Employee

Hi Antonio,

I do not recommend to use the debugger console way: because this slows down everything, as the debugger needs to catch the interrupt, read the characters, write them, etc. You don't want your students exposed to that. Even worse: this is not something they will (and should) use later in their projects. Using the debugger for something like this is just a nice demo feature, and that's it. I never used it because of that. If I recall, you would need to add special libraries for this, plus to enable 'semi hosting' in the startup code.

As you are using the FRDM-KL25Z board, why not using the USB CDC which comes with OpenSDA? You can use the normal UART of the KL25Z, and things get written over USB to the PC, even without a debugger.

You say that "my students would have to add lots of code files": I do not consider one .c and three .h files as 'a lot of files'?

In any case, if 4 files are too much: you can combine the three header files into one (just add what you need).

I really hope this helps.

Erich

PS: I'm teaching too, and I hope you are not teaching your class to use printf()? printf() is evil for embedded systems, and should be avoided whenever possible (Why I don’t like printf() ).

View solution in original post

0 Kudos
Reply
5 Replies
1,849 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

our expert Erich has  well documented this issue in his blog. see below:

http://mcuoneclipse.com/2013/04/17/printf-with-the-frdm-kl25z-board-and-without-processor-expert/

0 Kudos
Reply
1,849 Views
quevedo
Contributor V

I have seen this post already. However, I wanted to use the Debugger Console option instead of UART, if possible. Problem is, to use the UART without Processor Expert, my students would have to add lots of code files, and they are quite fresh for doing so.

If I cannot use Debugger Console option, I will just add a PE component for ConsoleIO, but I would prefer doing it without using Processor Expert.

0 Kudos
Reply
1,849 Views
BlackNight
NXP Employee
NXP Employee

Hi Antonio,

>>If I cannot use Debugger Console option, I will just add a PE component for ConsoleIO, but I would prefer doing it without using Processor Expert.

Maybe I'm confused, but printf() with the FRDM-KL25Z Board and without Processor Expert is *without* Processor Expert, and just needs 1 source file and 4 header files present in the project.

Erich

0 Kudos
Reply
1,849 Views
quevedo
Contributor V

Hi Erich,

My intentioni is simply to read simple variable values, in very basic aspects of programming. I will introduce UART communication much later in the course, and my intention is, at that point, to make students print out variables, using data conversion routines. I wanted to use printf in the beginning of the course, and as programs are slow, overhead would not be an issue.

Anyway, I am about to give up using shells right now, and following variables using debugger perspective and step-by-step execution. I want students to see code in action. And as this is a very basic course, I do not want them using Processor Expert. I may copy code from PE generated code, and hand it to students, but I want them to learn basics first. In another course, they will have the chance to use PE.

It is the first contact of our students with embedded programming, and first experiments must be very simple. I would love to share you what we are doing with this course some time. After I run this course for a full term, I will translate experiments to English.

Cheers

Antonio

0 Kudos
Reply
1,850 Views
BlackNight
NXP Employee
NXP Employee

Hi Antonio,

I do not recommend to use the debugger console way: because this slows down everything, as the debugger needs to catch the interrupt, read the characters, write them, etc. You don't want your students exposed to that. Even worse: this is not something they will (and should) use later in their projects. Using the debugger for something like this is just a nice demo feature, and that's it. I never used it because of that. If I recall, you would need to add special libraries for this, plus to enable 'semi hosting' in the startup code.

As you are using the FRDM-KL25Z board, why not using the USB CDC which comes with OpenSDA? You can use the normal UART of the KL25Z, and things get written over USB to the PC, even without a debugger.

You say that "my students would have to add lots of code files": I do not consider one .c and three .h files as 'a lot of files'?

In any case, if 4 files are too much: you can combine the three header files into one (just add what you need).

I really hope this helps.

Erich

PS: I'm teaching too, and I hope you are not teaching your class to use printf()? printf() is evil for embedded systems, and should be avoided whenever possible (Why I don’t like printf() ).

0 Kudos
Reply