Internal EEPROM custom address map

hello community,

I am developing one application using Arduino, which will store some settings to Arduino internal EEPROM.

I am creating the address map of all the settings using enumerations instead of #define preprocessor

like

enum{
setting1 = 1,
setting2 = 2
};

instead of

#define setting1 1
#define setting2 2

where 1 & 2 are the addresses of internal EEPROM
I have to create the map of ~900 bytes,
which method is better to create such custom address map ?

If all of the settings are a single byte then use an array. If you want named settings or if the values are not all single bytes then use a struct. An array or a struct can be written to and loaded from EEPROM using a single call to EEPROM.put() or EEPROM.get()

@UKHeliBob

I wanna create the names to specific location just like #define does

which one is better in terms of memory usage?

As the indexes into your address map are constants, I think they will not take up any data memory. How much data memory (i.e RAM) is used, depends on the variables that you want to store in it. If there are a mixture of bytes, ints, char strings etc, then use a struct like @UKHeliBob says in #2.

Easy to test, I would say :wink:

Is that because you are you going to read/write a single parameter ? It would be much safer to store the parameters in a struct, thus giving each of them a name, and to read/write the whole struct from/to the EEPROM when required

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.