Teensy 3.6 EEPROM issue

Status
Not open for further replies.

econjack

Well-known member
I am using a Teensy 3.6 under Win 10. No matter what variable I try to write to EEPROM, its value is not coming back correctly during a read. The following short program illustrates my problem:
Code:
#include <EEPROM.h>           // Standard with IDE

void setup() {
  int w;
  int i;
  
  Serial.begin(115200);
  while (!Serial)       // Make sure object is instantiated
    ;

  for (i = 0; i < 600; i++) {
      EEPROM.put(i, i);           // write 0-599
  }

  for (i = 0; i < 600; i++) {
      EEPROM.get(i, w);
      Serial.print(" ");
      Serial.print(w);             // read back the data in lines of 10 values
      if (i % 10 == 0)
        Serial.println("  ");
  }
}

void loop() {
}

The first several lines of output looks like:

50462976
67305985 84148994 100992003 117835012 134678021 151521030 168364039 185207048 202050057 218893066
235736075 252579084 269422093 286265102 303108111 319951120 336794129 353637138 370480147 387323156
404166165 421009174 437852183 454695192 471538201 488381210 505224219 522067228 538910237 555753246

However, if I hardcode the value 0 for the value in the first loop, the output is all 0's. This is going to be a flat forehead mistake, but I'm not seeing it. I'd appreciate any help cutting down the forest so I can see the trees.
 
Each integer is 4 bytes. But you're writing them every 1 byte in the EEPROM, so 3 bytes overlap with others you're writing.
 
Status
Not open for further replies.
Back
Top