adafruit / Adafruit_Learning_System_Guides

Programs and scripts to display "inline" in Adafruit Learning System guides

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArduinoISP.ino does not properly handle word-based address for EEPROM read/write

x0urc3 opened this issue · comments

Steps to reproduce
Reading and writing EEPROM using Adafruit ArduinoISP.ino will cause Bad EEPROM data. The official Arduino ArduinoISP.ino does not have similar issue. See avrdudes/avrdude/issues/990

Possible solution
The read and write EEPROM function does not handle word-based address. The high address byte is 0x00 in both function.

char eeprom_read_page(int length) {
// here again we have a word address
for (int x = 0; x < length; x++) {
byte ee = spi_transaction(0xA0, 0x00, _addr*2+x, 0xFF);
Serial.write( ee);
}
return STK_OK;
}

byte write_eeprom(int length) {
// here is a word address, so we use here*2
// this writes byte-by-byte,
// page writing may be faster (4 bytes at a time)
for (int x = 0; x < length; x++) {
spi_transaction(0xC0, 0x00, _addr*2+x, buff[x]);
delay(45);
}
return STK_OK;
}

Please submit a pull request if at all possible.

commented

FYI, Arduino's example has the fix back in Dec 2011.
arduino/arduino-examples@ea98fc8

Specific fix here.
rsbohn/ArduinoISP@bc480b0