eeprom-programmer
eeprom-programmer copied to clipboard
28c256 infinite loop while erasing
I modified the code so that it would overwrite the whole chip with 0xea. Turns out when i change the break condition in the erase loop to 32767 to match the size of the eeprom it goes into a seemingly infinite loop. My guess is that the 16 bit signed INT of the arduino overflows so that the break condition of the erase loop will never be met. Changing this to an unsigned INT solved the problem for me. But because of my inexperience with arduinos i could also be wrong.
Yes. The int variable address
is a signed 16-bit variable. That means it'll never be larger than 32,767. Instead, it'll wrap around to -32,768 and start over again. We can change the address
variable to a long
type:
// Erase entire EEPROM
Serial.print("Erasing EEPROM");
for (long address = 0L; address <= 0x7FFFL; address += 1L) {
writeEEPROM((int)address, 0xff);
if (address % 64 == 0) {
Serial.print(".");
}
}
Serial.println(" done");
As long as we don't send the writeEEPROM(int address, byte data)
method an address with more than 15 bits.