kd5rxt-mark
Well-known member
Setting the compiler optimization to "Smallest Code" seems to cause a fatal hang when writing to EEPROM on the T4.0. This can quickly be demonstrated using a slightly modified version of a small sketch that Paul posted in another thread where he was testing EEPROM write speed. I can't tell if the problem that I am seeing is unique to my specific Teensy4.0, or is in fact a problem on all T4.0s.
DETAILED NOTE: if a specific location in the EEPROM has previously been written to, the apparent hang may or may not occur. The hang can consistently be caused by writing 0xff to a specific location in EEPROM (which may or may not hang), then writing 0x00 to the same location (which always hangs). To make it easy to demonstrate in a single run, I modified Paul's simple sketch as follows:
Simply building this same code with the compiler optimization set to anything other than "Smallest Code" will always allow successful writes to the EEPROM on T4.0 using this simple test sketch.
Thanks,
Mark J Culross
KD5RXT
Edit: I posted <this> yesterday, but I think that post was in the wrong place. This post includes a much simpler way to demonstrate the problem, so the other can be deleted to avoid unnecessary cross-posting. MJC
DETAILED NOTE: if a specific location in the EEPROM has previously been written to, the apparent hang may or may not occur. The hang can consistently be caused by writing 0xff to a specific location in EEPROM (which may or may not hang), then writing 0x00 to the same location (which always hangs). To make it easy to demonstrate in a single run, I modified Paul's simple sketch as follows:
Code:
#include <EEPROM.h>
void setup() {
while (!Serial) ; // wait for Arduino serial monitor
Serial.println("EEPROM write time test - writing 0xff");
delay(25);
unsigned int begin_usec = micros();
EEPROM.write(9, 0xff);
unsigned int end_usec = micros();
Serial.print(end_usec - begin_usec);
Serial.println(" microseconds");
delay(1000);
Serial.println("EEPROM write time test - writing 0x00");
delay(25);
begin_usec = micros();
EEPROM.write(9, 0x00);
end_usec = micros();
Serial.print(end_usec - begin_usec);
Serial.println(" microseconds");
}
void loop() {
}
Simply building this same code with the compiler optimization set to anything other than "Smallest Code" will always allow successful writes to the EEPROM on T4.0 using this simple test sketch.
Thanks,
Mark J Culross
KD5RXT
Edit: I posted <this> yesterday, but I think that post was in the wrong place. This post includes a much simpler way to demonstrate the problem, so the other can be deleted to avoid unnecessary cross-posting. MJC
Last edited: