WDT issue?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

WDT issue?

Post by Barry914 »

I added a WDT to one of my projects and found it in a state where it was continuously and rapidly resetting itself. I enabled the WDT for 8 seconds in my code. It seems like the WDT is not reset when it fires, but it does not seem to remember the enable time when the application (or maybe the bootloader) starts. Do I need to do something in my code other than enabling the WDT and resetting it before it fires?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: WDT issue?

Post by adafruit_support_mike »

Rebooting the microprocessor doesn't disable the watchdog timer.

You need to disable the timer in your setup() routine, then re-enable it when you decide you need it.

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: WDT issue?

Post by Barry914 »

Does it revert to some default value after a reboot? It looks like it's resetting the processor about every half second or so.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: WDT issue?

Post by adafruit_support_mike »

The datasheet doesn't say anything about the WDT prescaler being changed, but a bit of web searching brings up plenty of complaints about interaction between the WDT and the bootloader.

I don't know specifically, but the bootloader may be setting its own values before handing execution over to the main code.

The easiest way to check would be to print the value of WDTCSR before and after a reset.

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: WDT issue?

Post by Barry914 »

I have revisited the WDT again and I think I know what is causing the odd WDT behavior, but I'm not sure what I need to do about it. Whatever is happening only happens if I load the sketch with a programmer instead of the bootloader. The only difference I am aware of is positional; the sketch overwrites the bootloader. I guess it's taking something with it, like maybe the WDT interrupt vector or handler? Any insight?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: WDT issue?

Post by adafruit_support_mike »

None I'm afraid. You'd have to take a look at the code for the bootloader to see what, if any, references it makes to the WDT.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”