Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

printf in embedded C compilers.

Status
Not open for further replies.

cmos babe

Full Member level 4
Joined
Jan 15, 2005
Messages
209
Helped
11
Reputation
22
Reaction score
0
Trophy points
1,296
Location
Dubai
Activity points
1,897
What I know is that printf is used to display strings on screen in PC programming. But What is it do in embedded C compilers?
 

In TI CCS for texas instrument's DSPs...it is used to display some information on the PCs monitor (e.g. value of some variable in the dsp's RAM) which is acquired using the JTAG port. If you're using the proceessor without connecting it to a PC, it just does nothing.
 

zeeshanzia84 said:
In TI CCS for texas instrument's DSPs...it is used to display some information on the PCs monitor (e.g. value of some variable in the dsp's RAM) which is acquired using the JTAG port. If you're using the proceessor without connecting it to a PC, it just does nothing.

Come on. I always see printf statements in embedded C programs.
 

Hi CMOS,
It is used the same as on the desktop environments. It depends on the compiler, but with most it just outputs a formated string to standard out, which may be an LCD, or serial port. In some compilers (HiTech, and perhaps C180 you have to write your own putc function for this to work. In others, like CCS, it outputs to which ever stream you define.
Hope this helps, but your question was not that specific, so...
Regards,
Robert
 

    cmos babe

    Points: 2
    Helpful Answer Positive Rating
I think the printf is only used for debugging in embedded C.
The compiler will compile printf , fopen etc into low level action , not as in PC's hello world .
The low level action will not print string for there is no screen.
It will be replaced by a debug instruction such as breakpoint. So when grogram runs at it , the debugger will know it and do the print job insteadly.
Maybe another way to use printf is that the printf will do special job according to special device .
 

What I know is that printf is used to display strings on screen in PC programming. But What is it do in embedded C compilers?

A concrete example for debugging using Docklight. Printf function is taking a lot of rom space from the mcu so it may not be good for end-product. However, it is good for program debug when there is no DSO or logic analyser.

John

www.TechToys.com.hk
 

    cmos babe

    Points: 2
    Helpful Answer Positive Rating
mean of printf is send the string to periperal (monitor with PC, COM with KeilC, . . . .) so with each complier has got the another.
Good luck for U !
 

In this case the default stream is usually a RS232/USB port..
 

For AVR C compilers, - I know Codevision - printf sends the formated string to the serial port RS232. It can be used mainly for debugging along with scanf - if you start hyperterminal, you can send and receive info with the uC, even if you dont have a keyboard or LCD connected to it. In CV AVR, there are some degrees of implementation for printf - short int, long int, float... printf takes about 1kwords of prog memory.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top