Arduino Forum

Using Arduino => Storage => Topic started by: curimania on Jul 11, 2019, 08:58 pm

Title: Eeprom behaves unpretictable
Post by: curimania on Jul 11, 2019, 08:58 pm
Hi
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

bitbucket.org/curi/arduinomidicontroller
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);
  delay(10);
  address = this->startAddress;
  firstChannels[1] = EEPROM.read(address + SECOND_BTN_TUPLE + BTN_FIRST_CHANNEL);
  delay(10);
  address = this->startAddress;
  firstChannels[2] = EEPROM.read(address + THIRD_BTN_TUPLE + BTN_FIRST_CHANNEL);
  delay(10);
  address = this->startAddress;
  firstChannels[3] = EEPROM.read(address + FOURTH_BTN_TUPLE + BTN_FIRST_CHANNEL);
  delay(10);
  address = this->startAddress;
  firstChannels[4] = EEPROM.read(address + FIFTH_BTN_TUPLE + BTN_FIRST_CHANNEL);
  delay(10);
  address = this->startAddress;
  firstChannels[5] = EEPROM.read(address + SIXTH_BTN_TUPLE + BTN_FIRST_CHANNEL);
  delay(10);
  address = this->startAddress;
  changeChannels(firstChannels);
  
  byte firstTypes[6];
  firstTypes[0] = EEPROM.read(address + FIRST_BTN_TUPLE + BTN_FIRST_TYPE);
  delay(10);
  address = this->startAddress;
  

Title: Re: Eeprom behaves unpretictable
Post by: Whandall on Jul 12, 2019, 07:07 pm
Is there something like
Do not ...
Yes.

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.
Title: Re: Eeprom behaves unpretictable
Post by: sterretje on Jul 13, 2019, 05:32 pm
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 (https://forum.arduino.cc/index.php?topic=148850.0), 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.
Title: Re: Eeprom behaves unpretictable
Post by: curimania on Jul 13, 2019, 09:02 pm
I added a small snipped which basically tepeats this way more times
Title: Re: Eeprom behaves unpretictable
Post by: Whandall on Jul 13, 2019, 09:05 pm
So I add a small snippet of the answer, you just have to...
Title: Re: Eeprom behaves unpretictable
Post by: curimania on Jul 13, 2019, 10:56 pm
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.
Title: Re: Eeprom behaves unpretictable
Post by: Whandall on Jul 13, 2019, 11:48 pm
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.

Title: Re: Eeprom behaves unpretictable
Post by: curimania on Jul 14, 2019, 10:33 am
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.
Title: Re: Eeprom behaves unpretictable
Post by: curimania on Jul 14, 2019, 10:50 am
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_PORT = /dev/ttyUSB0
ARDUINO_LIBS = EEPROM Wire NewliquidCrystal
DF_CPU = 16000000L
include /usr/share/arduino/Arduino.mk
Title: Re: Eeprom behaves unpretictable
Post by: GolamMostafa on Jul 21, 2019, 07:10 am
Quote
The probability that you are doing something wrong is immense.
You only show a small part of some gruesome code that does not compile.
Without all the missing defines and definitions you are expecting hint from someone.

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