Go Down

Topic: Speed of EEPROM.read() (Read 3356 times) previous topic - next topic

fkatzenb

All;
I am trying to reduce the amount of memory being used on my project.  Currently in setup(), I load about 18 bytes of data (2 8 byte size arrays and 2 single byte size constants) from EEPROM into two constant arrays and 2 constants that are 'global' variables to be used throughout the software.

The question is, "is EEPROM.read() as fast as calling the variables above?  If so, what are the draw backs?  

Thanks,
Frank

mem

It won't be as fast as reading the variable from RAM.  What is it in your sketch that is using up all the available RAM?

fkatzenb

Well I can post it tonight, but I am assuming it was using it up because it started getting hoky.  As I commented unessecary functions (unessecary at this time), and things returned to normal.

This is my first time programming something of this nature.  While I think I am doing a good job, I am not aware of tricks of the trade.  I am reading some of the site to try and ensure I don't have wasteful variables, etc.

mem


One of the first things to check is strings used for sending text over the serial port. You can save a lot of memory by putting these strings in program memory (progmem). There were some examples posted in a recent thread that you may want to search out and have a read. Note that progmem only works with variables that are defined and initialized at compile time and never change.  progmem is also explained in an article in the playground.

Another thing that can consume lots of RAM are big arrays. Sometimes you can get big reductions by using arrays of bytes instead of ints.

fkatzenb

Thanks mem.  You are a huge help.  One of the things that is hard moving from computer programming (C++, PHP, etc) is that it can be hard to think and compute with variables that are BYTE and you only need to display the data with LSBs when you push it over the serial port or display.

What I did last night was go back to basic operations, removing alot of 'features' and slim it down ensuring I am working with BYTEs when needed.  

I will check out the progmem stuff.  I have alot of stuff that is being printed over the serial port as a way to program some of the constants for computations.  So I am kind of string heavy.

Thanks!
Frank

mem

Hi Frank,

Sounds like there is a good chance that progmem could solve your memory problems

Good Luck

Go Up