9 years, 2 months ago.

printf: Why so much memory?

All, This may not be a problem. May be worth a (second) look by an admin

I use LPC812 max. When I include printf as a part of a serial port, it increase the code size by about 3kb. puts doesnt seem to take this much space. Given a 16kb code size, i thought this was quite high

Best Regards Siva S

3 Answers

9 years, 2 months ago.

It is because printf using whole chunk of the C++ stdio library, which is gigantic.

Addition, if size is your concern @sivasuren, write your own printf

posted by Martin Kojtal 11 Jan 2015
9 years, 2 months ago.

I assume this is for display purposes?

On a more constructive note, if you are interfacing a display, then you can choose a display where you do not need to use the printf function. For instance this display:

http://www.ebay.co.uk/itm/Serial-UART-I2C-SPI-Adapter-White-Blue-1602-LCD-for-Arduino-PIC-AVR-/370662529906?pt=LH_DefaultDomain_0&hash=item564d355b72

This code works for me when using the LPC812:

https://developer.mbed.org/users/shimniok/code/DigoleSerialDisp/

Hope this helps

9 years, 2 months ago.

puts() puts out a string, printf() has to interpret the % and build a string.