NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » LCD library in EEPROM

September 03, 2012
by eminthepooh
eminthepooh's Avatar

Hey guys, Seeing as how the LCD library header takes up about 45% of the 168's flash memory, I was wondering if there's any way to write the library to EEPROM, so that you can save program space in flash.

Thank you,

September 03, 2012
by pcbolt
pcbolt's Avatar

@eminthepooh

It's not really the LCD library that takes up the memory space, it is the "printf" family of functions. If you can get away with using just the Nerdkit LCD functions like "lcd_write_string()" and "lcd_write_int16()" and do all the formatting yourself, you can save some space. Using EEPROM space is much too valuable (and limited) for programming code. If you are able to use only the NK functions, you'd just have to comment out the following line from your makefile by putting a pound symbol in front of it:

LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
September 04, 2012
by Ralphxyz
Ralphxyz's Avatar

Using EEPROM space is much too valuable (and limited) for programming code.

What about using an external EEPROM? I suppose spped might be a issue.

Ralph

September 04, 2012
by Ralphxyz
Ralphxyz's Avatar

I suppose spped might be a issue.

Sorry, I sometimes stutter. That should be

I suppose "speed" might be an issue. (note also "an" always before a vowel, not "a issue" but "an issue")

Ralph

September 04, 2012
by Rick_S
Rick_S's Avatar

LOL at Ralph self correcting... LOL

Rick

September 04, 2012
by eminthepooh
eminthepooh's Avatar

Thank you very much PCBolt and Ralph for your suggestions. PCBolt was right, omitting printf family of functions reduced the size considerably.

Thanks guys,

September 04, 2012
by pcbolt
pcbolt's Avatar

@ eminthepooch -

I should clarify one or two things about the statements I made above. First, if you comment out the line from your "Makefile", you can still use the "printf" functions but when the compiler sees you are using them it will link in the library code and make your finished uploaded file bigger (but not "as" big). This line...

LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm

...will link in the largest amount of code since it is using the floating point libraries "printf_flt" and "scanf_flt" (not their actual file names). There is a third option using this line instead...

LINKFLAGS=-Wl,-u,vfprintf -lprintf_min -Wl,-u,vfscanf -lscanf_min

... will link in a minimized library that is only good for integers and strings. I've used it before and sometimes it's a pain but it can do simple formatting.

September 05, 2012
by Ralphxyz
Ralphxyz's Avatar

Well Rick, it's kinda slow around here, so I thought I'd throw in a English lesson with my correction.

Ralph

September 05, 2012
by Rick_S
Rick_S's Avatar

Wouldn't that be "an" English lesson... Tongue in Cheek

September 05, 2012
by Ralphxyz
Ralphxyz's Avatar

Damm

Post a Reply

Please log in to post a reply.

Did you know that a piezoelectric buzzer can be used to play music with your microcontroller? Learn more...