Browse Source

Prevent Watchdog reset writing Creality 4.x EEPROM (#20328)

Jason Smith 4 years ago
parent
commit
6f4381df53
No account linked to committer's email address
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp

+ 6
- 1
Marlin/src/HAL/STM32F1/eeprom_bl24cxx.cpp View File

@@ -48,6 +48,8 @@ bool PersistentStore::access_start()  { eeprom_init(); return true; }
48 48
 bool PersistentStore::access_finish() { return true; }
49 49
 
50 50
 bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
51
+  size_t written = 0;
52
+
51 53
   while (size--) {
52 54
     uint8_t v = *value;
53 55
     uint8_t * const p = (uint8_t * const)pos;
@@ -55,7 +57,10 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
55 57
     // so only write bytes that have changed!
56 58
     if (v != eeprom_read_byte(p)) {
57 59
       eeprom_write_byte(p, v);
58
-      delay(2);
60
+      if (++written % 128 == 0)
61
+        safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
62
+      else
63
+        delay(2);
59 64
       if (eeprom_read_byte(p) != v) {
60 65
         SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
61 66
         return true;

Loading…
Cancel
Save