Writing to EEPROM after every Arduino startup (even when reading or power up)
Closed this issue · 0 comments
The code for the programmer for the Arduino contains a serious bug that may cause random EEPROM writes every time it starts communicating with the board. Even when reading from the EEPROM .
In a typical Mega Arduino board, every time the at28c_programmer.py command is run and communication begins, the Arduino is reset and the setup function is executed.
Unfortunatelly the initialization sequence of control signals begins with setting the OE, WE, CS lines as output, and only later are they set to a high state.
Execution of functions
pinMode(OUTPUT_ENABLE, OUTPUT);
pinMode(WRITE_ENABLE, OUTPUT);
pinMode(CHIP_ENABLE, OUTPUT);
causes the outputs of the Arduino to go LOW value for a while, which can cause random EEPROM writes.
On my chips, mostly random values appear in the first memory cells.
In order to prevent this situation, I changed the code to
pinMode(CHIP_ENABLE, OUTPUT);
digitalWrite(CHIP_ENABLE, HIGH);
pinMode(OUTPUT_ENABLE, OUTPUT);
digitalWrite(OUTPUT_ENABLE, HIGH);
pinMode(WRITE_ENABLE, OUTPUT);
digitalWrite(WRITE_ENABLE, HIGH);
It prevented accidental writes.
These writes occurred every time the Arduino was reset, such as when the power was turned on.