Watch dog prevents software reset

I had a project that was freezing every now and then. I tried to find the cause but eventually added a Trinket to my circuit to reset my Core when it happened (super fun!). Once I got the timing correct, everything worked great with one exception, the Core can’t reset itself now. If I flash new code or my Core runs it’s periodic System.reset(), it will freeze and the trinket will eventually have to reset to Core. Everything works after the reset. If I flashed new code it stays solid magenta until reset. The new code runs once the Core gets going again. Is there something I can do to that will allow my Core to reset itself?

I’m running everything on 5v. The 5v Trinket looks for a signal from the Core’s A7 pin and pulls the reset pin low if too much time has passed. I added a the small capacitor on the reset/#2 line because the Trinket was resetting the Core during its setup().

Here is a picture of my setup if that is useful. Thanks for reading.

When you say freeze, what’s actually happening?

More information like:

  • sensors used
  • libraries used
  • System mode

would help us help you :wink:

Not sure what you meant by watchdog preventing a software reset…

Thanks for the reply @kennethlimcp and sorry if I wasn't clear.

The only connections to the Core are a string of WS2812B's and the Trinket (Core's A7 to Tinket #3, Core's Reset to Trinket #2). I'm using "FastLED/FastLED.h" and running in automatic mode.

Not sure what you meant by watchdog preventing a software reset..

I'm using the Trinket to reset the Core in case it gets stuck. When I have the Trinket connected to the Core's reset pin, I can't Flash or do a System.reset() call. If I'm flashing new code, the Core will blink rapid magenta for a bit, disconnect from the cloud, then breathe magenta until the watchdog/Trinket 3 min timer kicks in and pulls the reset pin low. If the Core runs its periodic System.reset() call, the Core will hang there too - it will begin the reset, but not be able to complete the shutdown/restart and again the watchdog/Trinket timer will kick in and then the reset goes fine. The core is not running any code once I try the OTA flash or it runs its System.reset().

If I disconnect the Trinket from the Core's reset pin, I can do OTA flash no problem. I suspect it would be able to do a System.reset() too. Hope that is clear. Thanks again for the reply.

Hmm it’s still not very clear for me though :confused:

Not sure why you hardcoded the Trinket to 3 minutes but what i would do is to use a digital pin from the core and toggle it digitalWrite(pin, !digitalRead(pin)). Once the trinket detects that the signal coming in is not toggling for more than…5-10 seconds, it will trigger a reset.

Of course this is not foolproof as during an OTA, user code stops running.

Can you explain more about why the Trinket needs to be there so that i can advice on how to change the user code and even remove the need for an extra Trinket? :wink:

This is what I'm doing with different timing. I toggle the Trinket pin every 5 seconds. If the Trinket doesn't hear from the Core in 3 mins, it triggers the reset. This part all works great. My question is more about the hardware connection.

On the Core:

void pingTrinket() { 
  if ( (millis() - lastPing) >= 5000 ) {
    lastPing = millis();
    s = !s; 
    digitalWrite(led, s); 
    digitalWrite(trigger, s); 
  }
}

On the Trinket:

if ((millis() - lastTriggerTime) > 180000) { 
digitalWrite(led, HIGH);
reset(); 
 }

void reset() { // here is the reset function
  digitalWrite(resetButton, LOW);
  delay(1000); 
  digitalWrite(resetButton, HIGH); 
  delay(60000); 
  lastTriggerTime = millis();
}

Obviously for this interaction to work, I need a connection from the Core reset pin to the Trinket pin. I would like to know how to properly make that connection. Once I wire these two pins together, I can't perform System.reset() call or complete at OTA flash without the Core freezing.

Hi @farmstand

I think your problem is that you are driving the RST line to +5V when not reseting. You say above you are running everything on 5V but the reset input is a 3.3V input. It already has a 10K ohm pull-up and a 0.1uF cap to ground.

Do you have a 3.3V Trinket to test with?

Or a level-shifter?

Or just an NPN transistor (and invert the logic in the Trinket program)?

2 Likes

Ah. I have a 74LVC245 somewhere. I think that will work… I will test that out. Thank you @bko! Thank you @kennethlimcp!

Thank you @bko! I used 10KΩ/15KΩ pair of resistors to get to 3v. I can now do an OTA flash and the Core fully cycles through its reset. Thanks again!

2 Likes