How do I get printf output to a console?

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get printf output to a console?

7,772 Views
Contributor III

How do I get printf() output to show up in a console window when debugging an application? Codewarror 10.1 and MQX 3.7.

18 Replies

24 Views
NXP Employee
NXP Employee

Hi, quite easy.

 

the MQX BSPs are set by default to output stdout - printf() to one of serial interfaces available on development board. Check Getting Started document for jumper setting and default interface you should use with your board.

 

PetrL

0 Kudos

24 Views
Contributor III

I'm using the TWR-K60N512-KIT.

 

Can you point me to the documentation that explains this? I have not found it. I have info on the jumper settings, but I don't see anything tying the jumper settings to the standard output.

 

Is the standard output by default going out the Serial port of the TWR-SER rather than thru the OSJTAG?

24 Views
Contributor III

I created a bareboard project with a printf and I get the output in the Console view of my CodeWarrior as I would expect. This leads me to suspect that there is an option in MQX somewhere to enable console output.

0 Kudos

24 Views
Contributor II

Hi, 

are you telling me you can see the output of your printf inside the console of your code warrior IDE? if why mine doesn't do that. could you please, help me to get the same result, explain it a bit more. 

thank,

0 Kudos

24 Views
NXP Employee
NXP Employee

Hi,

 

from MQX Getting Started:

 

Other Notes:

  •   The default console interface (ttyf:smileyhappy: is routed to OSBDM-COM (USB mini connector J13).Use the P&E Micro OSJTAG terminal to access board serial line.  
  •   To enable TWR-SER RS232 interface (TWR-SER) change the BSP_DEFAULT_IO_CHANNELconfiguration option to "ttyd:" in the mqx\source\bsp\twrk60n512\twrk60n512.h file.

PetrL

0 Kudos

24 Views
Contributor III

I am assuming that the bareboard program that works redirected standard output to the OSBDM-COM which is displayed in the CodeWarrior Console window. I want my MQX program to do the same.

The twrk60n512.h has BSP_DEFAULT_IO_CHANNEL defined as "ttyf:".

I am using the "hello_twrk60n512" project.

What else can I check?

 

0 Kudos

24 Views
Contributor III

If I run "Terminal Window application v2.00" from PEMicro connected to USB COM, I get my standard output in there.

 

0 Kudos

24 Views
NXP Employee
NXP Employee

The default console (ttyf) on TWR-K60 board is routed to board OS-JTAG. If you want to change it to TWR-SER board, add following code to user_config.h and recompile BSP library

 

// For polling mode

#define BSPCFG_ENABLE_TTYD       1

#define BSP_DEFAULT_IO_CHANNEL                        "ttyd:"    /* TWR-SER   polled mode   *

/#define BSP_DEFAULT_IO_CHANNEL_DEFINED

 

OR 

 

// For interrupt mode

#define BSPCFG_ENABLE_ITTYD       1

#define BSP_DEFAULT_IO_CHANNEL                        "ittyd:"    /* TWR-SER   interrupt mode   *

/#define BSP_DEFAULT_IO_CHANNEL_DEFINED

0 Kudos

24 Views
Contributor III

I want to get the standard output to show in the Console window of Codewarrior. Like the Bareboard project does. The default "ttyf:" does not do this.

0 Kudos

24 Views
NXP Employee
NXP Employee

The CodeWarrior console is not supported in MQX at the moment. The console support has been added as new feature request for future releases of MQX.

0 Kudos

24 Views
Contributor II

I can not to have the printf output on console in a simple design (without MXQ and Process Expert). In particular with the "helloword" adn "gpio" in the project file as "KINETIS512_SC.zip". I use the TWR-K60N512-KIT.
is it possible in this case to get printfout on console?

0 Kudos

24 Views
NXP Employee
NXP Employee

Hi Alex,

The SC code base is setup to use the virtual Terminal from P&E Microsystems (register on their sight and goto http://www,pemicro.com/osbdm to get the latest OSBDM Virtual Serial Toolkit.

 

To change the default setting from virtual to SCI/serial port open the k60_tower.h and make below changes:

/*
 * Select the serial port that is being used below. Only one of the
 * options should be uncommented at any time.
 */
#define SERIAL_CARD     // this is the default option, so it is uncommented
// #define OSJTAG         // use this option for serial port over the OS-JTAG circuit
 

Hope this helps.

Regards,

David

FYI Not certain if all works with the IAR6.2....I'm using the IAR6.10.5 currently.

0 Kudos

24 Views
Contributor II

Sorry David,

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'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

24 Views
NXP Employee
NXP Employee

Hi Alex,

With the QSD application loaded on your hardware and the CW10.1 debugger running, using the following steps:

- Window-->Show View-->Other...-->Terminal-->Terminal   to open a terminal window.

- Click the "Settings" icon

- Set Connections Type to Serial, configure rest of Settings as you would for any terminal window utility (115200/8/1/None/None).

Click OK and you should now have a terminal window working in CW10.1 that displays the printf()'s.

 

Hope this helps.

Regards,

David

0 Kudos

24 Views
Contributor II

Hi

 

thank all for your help, when I configure the terminal windows I don't see port number to configure, how can I solve that?

 

 

To get output on eclipse windows console I've solved the problem in the following way.

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

24 Views
NXP Employee
NXP Employee

Hi Alex,

Not certain I understand your question so will try to answer in two ways and hope one is correct for you.

1)

To determine which COM port on the PC is being used is the tricky part.

If your PC has a DB9 serial connector then it is "usually" COM1 or COM2.  You just have to try chaning settings of terminal to find out.

If you are using a USB to serial converter, then open the Device Manager--> Ports (COM & LPT) .  That should show you which COM port the USB to Serial cable enumerated to (assuming you have it plugged in!).

 

2)

Once the Terminal Windows has been added to your perspective (Window-->Show Views-->Other-->Terminal-->Terminal) and in the newly displayed Terminal Window you select the "Settings" icon (looks like a yellow piece of paper with a light blue strip at top) there is a pull-down next to "Port:" to select which COM device you want to access.

If you do not see an COM chooses.....I don't what is wrong as mine displays the most recent used.  You might have to update your CW10.1.

 

Thanks for elaboration on the serial vs virtual serial port setup.  That is helpful for others.

Regards,

David

0 Kudos

24 Views
Contributor II

Hi Davis,

Now that I am also facing the same problem, I need some guidance on the issue. I think I can describe the porblem once again.

All TWR kits use OSBDM (using JM60) and then PE provides utility to capture some Virtual Serial port generated which is (i1....see the attachment).

Traditionally we have been using this utility to get the serial data from our board.

 

Now when I start using some of the other examples with Tower boards which use "printf", I expect to see the output somewhere either in "Termincal Utiltiy provided by PE" or the "Console" suggested  or some other Utility such as Hyperterminal.

 

This is where we face a problem.

(1) We don't know where in the code should I select the UARTS being used by "Printf".(how OSBDM is using UART and its USB is obvious)

(2) Just becuase Serial-USB port appears under "Jungo" on my Windows XP(please see the attachment), this dosn't figure in any of the Serial utilities (other than the one supplied by PE Micro).

 

Problem in nutshell: How do I make select a particular UART for "printf" (It must be using some UART to send these characters....that's the assumption.

 

0 Kudos

24 Views
Senior Contributor III

Hello vivacious,

 

your enquires were definitely asnwered here on the forum or are in documentation (Gettin started) .

 

1. yourboard.h in your board bsp folder. Look for BSP_DEFAULT_IO_CHANNEL. This define selects default IO channel.

 

2. Older OSJTAG firmwares are compatible only with PE MICRO terminal. There exists Terminal redirector to redirect output to the COM port which should work with any console application. Newer version (as I remember firmwares above 31.01 are CDC automatically). Update could be found on the PE micro website.

 

Regards,

MartinK

0 Kudos