PDA

View Full Version : Detect reset by WDT



Art
- 12th April 2010, 13:18
Hi Guys,
Is there a way to detect in a program whether the program is starting
from a power on reset or a reset forced by the watchdog timer?
Cheers, Art.

Acetronics2
- 12th April 2010, 13:22
Hi, Art

Yess, of course !

see the RESET chapter of the PicŪ Datasheet you use. i.e. Table 14.4 for the 16F628a ...

Everything explained for the registers to check.

Alain

Art
- 12th April 2010, 22:32
I didn't see a reset chapter, but did notice that T1CON register is always set
to zero on powerup, but remains unchanged for any other reset.
Since I'm not using timer 1, I just set one of the prescaler bits somewhere
in my program, and then check for the value of T1CON where I want to check
whether reset was caused by watchdog timer.

HenrikOlsson
- 13th April 2010, 06:00
Art,
Which PIC are you using? On the 18F2431, for example, there's the RCON register which contains the bits telling you what caused the reset. In this case RCON.3 ill be '0' when the WDT timed out and caused a reset.

/Henrik.

Art
- 13th April 2010, 07:28
The chip is an old 16F628.

HenrikOlsson
- 13th April 2010, 08:14
Hi Art,
It looks like STATUS.4 is the bit you want to check, '0' if the WDT caused a reset.

/Henrik.

Art
- 13th April 2010, 08:34
Ah, I see, TimeOut bit, thanks :)