Go Down

Topic: Can't save data in Arduino EEPROM (Read 1 time) previous topic - next topic


I'm using the sparfun's AVR pocket programming...

I'll try using the USB.


Mar 21, 2011, 08:39 pm Last Edit: Mar 21, 2011, 08:45 pm by retrolefty Reason: 1

Look at the EEPROM::write() function. Notice, in particular, what the type of the 2nd argument is. Then, compare that to the types of the arguments that you provide.

If you were to call the function with the correct type of argument, you would get correct results.

If that is the root of the problem, then part of the blame might be the example sketch used in the Arduino reference section for EEPROM:


Code: [Select]
#include <EEPROM.h>

void setup()
 for (int i = 0; i < 512; i++)
   EEPROM.write(i, i);

void loop()

And I ran the OP's sketch and it seemed to work fine writing to eeprom, and later after commenting out the writting to eeprom, still held and printed valid data from the eeprom.



I upload the sketch using the bootloader instead the Pocket programmer and it works fine.

then, the pocket programmer clears the IC and rewrites it????

The example works fine but it's incorrect.
Then I have to tear apart the value (integer)  in two bytes to save... and when I need to retrieve the value I need to call both bytes and "paste them" ???

How to do that ????


Write 16 bit integer 'value' into i and i+1:

  EEPROM.write(i, value>>8);   // Write high byte
  EEPROM.write(i+1, value);  // Write low byte

Read 16-bit integer 'value' from i and i+1:

value = (EEPROM.read(i) << 8) | EEPROM.read(i+1);
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e


"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up