diff --git a/ArduinoISP/ArduinoISP/ArduinoISP.ino b/ArduinoISP/ArduinoISP/ArduinoISP.ino index 7f327e64c..e31449975 100644 --- a/ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -488,8 +488,10 @@ 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) + int start = _addr*2; for (int x = 0; x < length; x++) { - spi_transaction(0xC0, 0x00, _addr*2+x, buff[x]); + int addr = start + x; + spi_transaction(0xC0, (addr >> 8) & 0xFF, addr & 0xFF, buff[x]); delay(45); } return STK_OK; @@ -497,8 +499,9 @@ byte write_eeprom(int length) { void program_page() { byte result = STK_FAILED; - int length = 256 * getch() + getch(); - if (length > 256) { + unsigned int length = 256 * getch(); + length += getch(); + if (length > param.eepromsize) { Serial.write(STK_FAILED); error++; return;