I am able to run the following code on an Arduino board and it works as expected by retrieving stored values from EEPROM. When it is run on the Teensy 3, the values retrieved from the EEPROM after powering it off are not as expected.
On the Arduino - the values in memory correctly reflect the increasing index. On the Teensy 3 - I am getting the value 255 in each memory index.
OS: Windows 7 64-bit
Steps to reproduce
1) Upload/Run the code below to store some values in EEPROM
2) Comment out the first_time() function
3) Upload/Run the code again to display the stored values
I'd like to know if someone can validate this is an issue on the Teensy 3- or that my code is wonky.....
Thanks!
-------------------------------------------------------------------------------------------------------------------------------------------
#include <EEPROM.h>
#define VALUES 26
void setup()
{
Serial.begin(38400);
first_time(); // comment out after first run - used to store values in EEPROM
delay(3000); // delay so we have time to launch terminal
display_values();
}
void loop()
{
}
void first_time()
{
for (byte x=0; x<VALUES; x++)
EEPROM.write(x,x);
}
void display_values()
{
for (byte x=0; x<VALUES; x++)
{
Serial.print("Position: "); Serial.print(x); Serial.print(" Value: "); Serial.println(EEPROM.read(x));
}
}
On the Arduino - the values in memory correctly reflect the increasing index. On the Teensy 3 - I am getting the value 255 in each memory index.
OS: Windows 7 64-bit
Steps to reproduce
1) Upload/Run the code below to store some values in EEPROM
2) Comment out the first_time() function
3) Upload/Run the code again to display the stored values
I'd like to know if someone can validate this is an issue on the Teensy 3- or that my code is wonky.....
Thanks!
-------------------------------------------------------------------------------------------------------------------------------------------
#include <EEPROM.h>
#define VALUES 26
void setup()
{
Serial.begin(38400);
first_time(); // comment out after first run - used to store values in EEPROM
delay(3000); // delay so we have time to launch terminal
display_values();
}
void loop()
{
}
void first_time()
{
for (byte x=0; x<VALUES; x++)
EEPROM.write(x,x);
}
void display_values()
{
for (byte x=0; x<VALUES; x++)
{
Serial.print("Position: "); Serial.print(x); Serial.print(" Value: "); Serial.println(EEPROM.read(x));
}
}