From 6dfcd491d02a6ad99c0d43d92da0b14d76d67228 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sat, 19 Dec 2020 21:55:57 -0800 Subject: [PATCH] Fix Creality EEPROM watchdog freq. (#20510) --- Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp b/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp index 9a7e4d799d49..a6395698aae7 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp @@ -48,6 +48,7 @@ bool PersistentStore::access_start() { eeprom_init(); return true; } bool PersistentStore::access_finish() { return true; } bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + size_t written = 0; while (size--) { uint8_t v = *value; uint8_t * const p = (uint8_t * const)pos; @@ -55,7 +56,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui // so only write bytes that have changed! if (v != eeprom_read_byte(p)) { eeprom_write_byte(p, v); - if (size & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes if (eeprom_read_byte(p) != v) { SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); return true;