User Tools

Site Tools


en-us_commands:reference:wdt_disable

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en-us_commands:reference:wdt_disable [2026/09/07 23:35] – 바깥 편집 127.0.0.1en-us_commands:reference:wdt_disable [2026/09/14 20:30] (current) – external edit 127.0.0.1
Line 14: Line 14:
  
 ===== Example ===== ===== Example =====
 +
 +This example uses MPINO-16A8R8T digital input D22. When D22 becomes HIGH, it disables the watchdog once and does not enable it again.
  
 <code cpp> <code cpp>
 +bool watchdogActive = true;
 +
 void setup() { void setup() {
-#if defined(__AVR_ATmega2560__) +  WDT_ENABLE(WDT_2S);  // Start the two-second watchdog.
-  WDT_ENABLE(WDT_2S);  // Set the watchdog timeout and start operation. +
-#elif defined(__AVR_ATmega128__) +
-  WDT_ENABLE(WDT_1800MS);  // Set the watchdog timeout and start operation. +
-#endif+
 } }
  
 void loop() { void loop() {
-  const bool maintenanceMode = IdigitalRead(0, 5);  // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. +  if (watchdogActive && digitalRead(22== HIGH) { 
-  if (maintenanceMode) { +    WDT_DISABLE();  // Disable the watchdog when D22 becomes HIGH
-    WDT_DISABLE();  // Stop the watchdog. +    watchdogActive = false;
-    return;+
   }   }
-  WDT();  // Refresh the watchdog before its timeout expires.+  if (watchdogActive) WDT();  // Feed the watchdog only while it is active. 
 +  delay(100);
 } }
 </code> </code>
Line 39: Line 39:
   * Do not set a timeout shorter than the longest normal processing time.   * Do not set a timeout shorter than the longest normal processing time.
   * Do not hide program faults by placing ''WDT()'' where it always executes unconditionally.   * Do not hide program faults by placing ''WDT()'' where it always executes unconditionally.
 +
 +===== Built-in Commands in the Same Category =====
 +
 +  * [[:en-us_commands:reference:wdt_enable|WDT_ENABLE() View detailed description]]
 +  * [[:en-us_commands:reference:wdt|WDT() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/wdt_disable.1788791736.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki