Go Down

Topic: Eeprom behaves unpretictable (Read 181 times) previous topic - next topic


Jul 11, 2019, 08:58 pm Last Edit: Jul 13, 2019, 09:01 pm by curimania
I am building a midi Controller with an mega and want to save and load settings with the eeprom but some how it seems that it changes stuff like the addresses by itself.
I was trying multiple Versions of an eeprom library and also things like writing and reading works if only done with test data and not my objects.

Is there something like
Do not use multiple write and read calls after each other
Do not use defines for addresses
Do not use objects to write th3 read data

I am really frustrated as I used eeprom before for example on an uno for saving timer data and such but as extensive as in This project I guess

For the full project if you want to have a Look.

I do not susbect anybody to Remotely and magically solve my Problem but maybe you have some Tricks and Tipps for me.

Otherwise I will have to Look into SD cards and parsing Text files I guess

Code: [Select]

void ButtonSwitch::loadBtnFromEeprom()
  int address = this->startAddress;
  byte firstChannels[6];
  firstChannels[0] = EEPROM.read(address + FIRST_BTN_TUPLE + BTN_FIRST_CHANNEL);
  address = this->startAddress;
  firstChannels[1] = EEPROM.read(address + SECOND_BTN_TUPLE + BTN_FIRST_CHANNEL);
  address = this->startAddress;
  firstChannels[2] = EEPROM.read(address + THIRD_BTN_TUPLE + BTN_FIRST_CHANNEL);
  address = this->startAddress;
  firstChannels[3] = EEPROM.read(address + FOURTH_BTN_TUPLE + BTN_FIRST_CHANNEL);
  address = this->startAddress;
  firstChannels[4] = EEPROM.read(address + FIFTH_BTN_TUPLE + BTN_FIRST_CHANNEL);
  address = this->startAddress;
  firstChannels[5] = EEPROM.read(address + SIXTH_BTN_TUPLE + BTN_FIRST_CHANNEL);
  address = this->startAddress;
  byte firstTypes[6];
  firstTypes[0] = EEPROM.read(address + FIRST_BTN_TUPLE + BTN_FIRST_TYPE);
  address = this->startAddress;


Is there something like
Do not ...

Do not ask questions without posting complete code (often a minimal example showing the error works best).
Do not assume that Strings can be saved to EEPROM without effort.
Do not write single cells too often.
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)


Jul 13, 2019, 05:32 pm Last Edit: Jul 13, 2019, 05:33 pm by sterretje
Hmm, need to login on that bitbucket site. So that's a no.

Post your code here (please read How to use this forum - please read, specifically point 7 about posting code and if the code exceeds 9kB, point 8 about attaching files).

Or even better, as said above, a simple example that shows your problem.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.


I added a small snipped which basically tepeats this way more times


So I add a small snippet of the answer, you just have to...
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)


Very Funny indeed.
I think this is a problem caused by the repetetive usage of wiriting to different addresses repeateadly, so I really think my repetetive Code which as said is the added Code over and over again will not really help in under standing my Problem.
Maybe it is even caused by using the cli interface on a Linux System for compiling and uploading sketches.
Maybe it is because c11 did not Support things I used in my Code.
Maybe it is because the eeprom library is not that stabile on an mega.
Never the less. Thanks for your time and sorry for the inconvience but I guess I will just add a SD card.


The probability that you are doing something wrong is immense.

You only show a small part of some gruesome code that does not compile.

How could someone even give a hint without all the missing defines and definitions?

If you are interested in solving the issue, provide a compiling example of the error.
And a decent description how the actual behaviour differs from your expectations.

BTW working with EEPROM is much simpler than using an SD card.

Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)


My projects is compiling without error and also uploads and runs.
The only thing that is weird is that it seems to load and save to ever changing addresses.
I will Post the whole project files when beeing at a computer again and not fiddeling on an Smartphone.


Jul 14, 2019, 10:50 am Last Edit: Jul 14, 2019, 10:52 am by curimania
Here are alle the files from my repo never the less

And the makefile:

ARDUINO_DIR = /usr/share/arduino-1.8.8/
BOARD_TAG = mega
BOARD_SUB = atmega2560
ARDUINO_LIBS = EEPROM Wire NewliquidCrystal
DF_CPU = 16000000L
include /usr/share/arduino/Arduino.mk

Go Up