How do I get printf output to a console?

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

How do I get printf output to a console?

5,699 Views
AlexGiov
Contributor II

I can not to have the printf output on console in a simple design (without MXQ and Process Expert).

My configuration is:CW10.1 based on eclipe, TWR-K60N512-KIT, and I debug the project "helloword" adn "gpio" in the code example "KINETIS512_SC.zip".
is it possible in this case to get printfout on console?

6 Replies

2,243 Views
Jiun_Yong
Contributor III

I got the gpio demonstartion working last week, so I may be able to help 

 

Once you have opened the gpio project, go to the "Sources" folder, then the "platforms" forder and open file k60_tower.h

 

At the end of this file is a section titled /* * Serial Port Info */

 

If you are using the tower with the separate serial/USB/Ethernet ports then uncomment the line 

#define SERIAL_CARD     // use this option for serial port on TWR-SER

and comment out the line

//#define OSJTAG         // use this option for serial port over the OS-JTAG circuit

 

Rebuild the project and debug.

 

Connect the serial port on the tower to a serial port on your PC, and use Hyperterminal - set the communications speed to 115200 baud.

 

Good luck!

 

0 Kudos
Reply

2,243 Views
AlexGiov
Contributor II

Sorry

I explained badly the problem that I have.
I am using CodeWarrior 10.1 (based on eclipse) on windows 7
I would like to get printf output to the console windows of CodeWarrior (based on Eclipse).

I use this setting but i can get the printf output on eclipse window console:

//#define SERIAL_CARD     // use this option for serial port on TWR-SER
#define OSJTAG         // use this option for serial port over the OS-JTAG circuit

 

Alex

http://www,pemicro.com/osbdm
0 Kudos
Reply

2,243 Views
AlexGiov
Contributor II

Sorry again...

 

I would say:

 

i CAN'T get the printf output on eclipse window console:

//#define SERIAL_CARD     // use this option for serial port on TWR-SER
#define OSJTAG         // use this option for serial port over the OS-JTAG circuit

 

Alex

 

0 Kudos
Reply

2,243 Views
gustavod
Contributor III

Hi Alex,

 

In our demo we use the printf for console and it is working. You can download the code here:

http://code.google.com/p/brtos/downloads/list

 

We used the console printf for Thread-Metric analysis, like this:

printf("**** Thread-Metric Basic Single Thread Processing Test **** Relative Time: %u\n\r", relative_time);

 

If you do not have TWR-LCD i would like to recommend you this demo:

http://brtos.googlecode.com/files/BRTOS%201.65%20Kinetis%20-%20USB.rar

 

Have you ever tried to mark the option in the attached figure?

 

Best regards,

Gustavo

0 Kudos
Reply

2,243 Views
AlexGiov
Contributor II

Hi all,

 

thank all for your help.

I've solved my problem.

A little report.

Gustav your examples compile perfect and put the printf out directly on eclipse console (i've downloaded the builded code into flash).

The freescale example in "KINETIS512_SC.zip" put the code only on serial card (TWR-SER) or OSJTAG. This's because in this example it's writen a new printf function (printf.c) declared in io.h. So if you use the printf in printf.c you get output on TWR-SER or OSJTAG.
To get printf output on eclipse console you need to use # include <stdio.h> instead of # included "io.h" and do not compile printf.c

Explained by code:
common.h:
/*
 * Include common utilities
 */
    /* Alex:
     * to get output through serial port (OSJTAG or SERIAL_CARD on TWR-SER)
     */
//#define IO_ON_SERIAL
#define IO_ON_ECLIPSE_CONSOLE

#include "assert.h"

//Alex: including the IO
#if (defined(IO_ON_SERIAL))
#include "io.h"
#elif (defined(IO_ON_ECLIPSE_CONSOLE))
#include <stdio.h>
#else
#error "Alex: No IO defined!!!"
#endif

printf.c
/*
 * File:        printk.c
 * Purpose:     The standard C library routine printf(), but without
 *              all the baggage.
 */

#include "common.h"
/* Alex:
 * Compile this file only if you want IO on serial card or OSJTAG
 */
#if (defined(IO_ON_SERIAL))
#include <stdarg.h>

/********************************************************************/

typedef struct
{
    int dest;
    void (*func)(char);
    char *loc;
} PRINTK_INFO;

int  ...continue the printf...

Alex.

0 Kudos
Reply

2,243 Views
PaoloRenzo
Contributor V

Hi

 

I use the following file to redirect to external serial port. Look at the example code. This is the same as semihosting or retarget concept coming from other ARM compilers.

 

Hope this helps

0 Kudos
Reply