Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Hitting Watchdog Too Often

  1. #1

    Hitting Watchdog Too Often

    Why does hitting the watchdog too often not reset the watchdog timer? The following code causes a reset on the Teensy 3.2.
    Code:
    #include <Adafruit_SleepyDog.h>
    
    void setup() {
      Watchdog.enable(5000);
      delay(1000);
      Serial.begin(115200);
      Serial.setTimeout(10);
      delay(100);
      Serial.println("Setup");
    }
    
    void loop() {
      Watchdog.reset();
      // comment the following line to cause a reset.
      delay(1000); Serial.println(".");
    }

  2. #2
    Junior Member
    Join Date
    Apr 2018
    Posts
    3
    Try with:

    Code:
    #include <Adafruit_SleepyDog.h>
    
    elapsedMillis wdMillis;
    
    void setup() 
    {
       Watchdog.enable(5000);  
    }
    
    void loop() 
    {
    
      if (wdMillis > 4900)
       {
          wdMillis = 0;
          Watchdog.reset();
       }  
    }

  3. #3
    I understand that the watchdog is typically reset just before the timer expires. I am more interested in why it doesn't work if it is reset too often.

  4. #4
    Senior Member
    Join Date
    May 2017
    Posts
    202
    The underlying ARM processor implements a windowed watchdog, and will reset on too fast or too slow watchdog service intervals. It looks like the default value for the lower counter is 16 ( which may or may not represent 16 ms. You can test that with your program ).

    Edit: Looking further it appears the windowed mode is not enabled in the status register.
    Last edited by rcarr; 05-16-2019 at 06:42 PM.

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,379
    With nothing else in loop() that reset() is being called at least a couple hundred thousand times per second on a T_3.2.

    I put the code in a sketch and without waiting at least/about 970 microseconds with a delay between calls the watchdog would restart the processor as if watchdog was not reset().

    Since I had to download the library I glanced at it - the reset() call :: Disables interrupts, writes the needed values to reset the timer, then Enables interrupts. That interrupt toggle could be generally disruptive of normal operation and function.

    The watchdog code/implementation seems to deal with millisecond time intervals and calling it every few microseconds … up to that 970 us … is just not how it was designed to be used - or perhaps as @rcarr notes perhaps updates too fast are defined as another way the watchdog defines failure - the processor docs would detail that.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,929
    This is indeed a strange problem. The watchdog somehow getting into windowed mode does seem like the only plausible explanation, but I can't see how that could be happening.

    I am currently at Maker Faire in San Mateo, so writing this from my laptop in a hotel room without access to my workbench & tools. If I miss this when I get back on Tuesday, please ping me with a reminder. I'd really like to dig into why this is happening, when I have access to my tools.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •