How to tie my serial port driver into printf

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

How to tie my serial port driver into printf

584 Views
lslonim
Contributor II

Hi, I'm using CW 11.1 because my processor is MC9S08DZ60A. I am porting some code from another compiler. The existing code tied its serial port driver into printf by coding a function named putchar. But when I try to build that function, I get a whole bunch of weird compiler errors.

Here is the code:

int putchar( char c ) /* stdio - for printf to use */
{
sci_write(c);
return(c);
}

The errors I get on the first line of the function are:

Multiple markers at this line
- C2801 ')' missing
- C2801 ';' missing
- C1815 c not declared (or typename)
- C5002 Illegal type
- Syntax error

I am so confused. Is putchar a macro and not a function? What is the right way to tell printf I want it to use my serial driver? Any suggestions appreciated.

Thanks,

Lloyd

0 Kudos
Reply
1 Reply

562 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello @lslonim 

printf() is not possible since there is NO "standard output" in CodeWarror HCS08. User has to implement their own "pseudo" prinf() function, i.e. to format the output in memory and then print out through SCI.

Please put an #include "termio.h"  statement in the code. We can find this file under CodeWarrior install folder.

The following code runs successfully on QG8. You can refer it on DZ60. The method is the same,

ZhangJennie_1-1745214484292.png

 

ZhangJennie_0-1745214446908.png

 

Thanks,

Jun Zhang

 

0 Kudos
Reply