How do I get printf() output to show up in a console window when debugging an application? Codewarror 10.1 and MQX 3.7.
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.
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?
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.
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.
from MQX Getting Started:
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?
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 *
// For interrupt mode
#define BSPCFG_ENABLE_ITTYD 1
#define BSP_DEFAULT_IO_CHANNEL "ittyd:" /* TWR-SER interrupt mode *
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?
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.
FYI Not certain if all works with the IAR6.2....I'm using the IAR6.10.5 currently.
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
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.
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:
* Include common utilities
* to get output through serial port (OSJTAG or SERIAL_CARD on TWR-SER)
//Alex: including the IO
#error "Alex: No IO defined!!!"
* File: printk.c
* Purpose: The standard C library routine printf(), but without
* all the baggage.
* Compile this file only if you want IO on serial card or OSJTAG
int ...continue the printf...
Not certain I understand your question so will try to answer in two ways and hope one is correct for you.
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!).
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.
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.
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.