1

my Attiny85 losts the whole EEPROM data, if I turn the power of. I use the Arduino IDE and I'm sure, that The EEPROM was wrote, because I get Serial feedback. Here my code:

#include <EEPROM.h>
#include <SoftwareSerial.h>

SoftwareSerial SSerial(0, 1);

int addr = 0;
uint8_t val = 2;

void setup()
{
  SSerial.begin(9600);
}

void loop()
{
  EEPROM.write(addr, val);

  delay(100);

  uint8_t value = EEPROM.read(addr);

  SSerial.print(addr);
  SSerial.print("\t");
  SSerial.print(value, DEC);
  SSerial.println();

  addr = addr + 1;
  if (addr == 512)
    while(1);
}

Thank you :)

SPJS01Pro
  • 79
  • 1
  • 11
  • Do not write eeprom in a loop, it may damage it. You are using variable address, which is not declared – Vladimir Tsykunov Apr 14 '16 at 12:40
  • Are you sure that is the code you tried. `address` isn't defined anywhere. Have you killed the EEPROM by leaving write code looping for too long during testing? – Chris A Apr 14 '16 at 12:40
  • The loop does only run once. – SPJS01Pro Apr 14 '16 at 12:44
  • No, `loop()` will be ran 512 times and will be caught in `while(1);` – MikeCAT Apr 14 '16 at 12:47
  • In your previous tests maybe? I recall you're last question you had it looping continuously in your original code. – Chris A Apr 14 '16 at 12:47
  • Please have a look to the code, I've edited it. – SPJS01Pro Apr 14 '16 at 12:51
  • I tried it with another Attiny85, it doesn't work. – SPJS01Pro Apr 14 '16 at 12:56
  • 1
    How do you know whether the eeprom content was lost? Did you program it again? I don't know whether the programming erases or not the eeprom... Try reading the whole eeprom (and dumping it) in the setup. Moreover.. Why do you use software serial instead of hardware? – frarugi87 Apr 14 '16 at 13:09
  • Why do you use `loop()` to do the writing loop instead of something like `for(addr = 0; addr < 512; addr = addr + 1) { ... }`? – MikeCAT Apr 14 '16 at 13:33
  • 1
    @frarugi87 programming through ISP SPI erases eeprom (all values become 0xFF) by default but seems this feature can be setup in programmer settings. Programming through bootloader do not erase eeprom. – Vladimir Tsykunov Apr 14 '16 at 13:58
  • Thank you! I have a read only scetch, but I think my problem is my ISP. Thanks alot! – SPJS01Pro Apr 14 '16 at 14:49
  • @SPJS01Pro Try to implement the reading at the beginning of your sketch, without uploading a new one, and yhou'll see that the data is there again.. – frarugi87 Apr 14 '16 at 15:32

1 Answers1

3

Programming through ISP SPI erases eeprom (all values become 0xFF) by default but seems this feature can be setup in programmer settings. Programming through bootloader do not erase eeprom.

Thank you @Vladimir Tsykunov

SPJS01Pro
  • 79
  • 1
  • 11