| Author |
Message |
mrcube_ns
Joined: 10 Apr 2002 Posts: 429 Helped: 11 Location: Dark side of the Moon
|
11 Dec 2003 15:18 Watchdog in AT89S8252 ?!? |
|
|
|
|
I need to use watchdog in AT89s8252 (I new in atmel programming).
How to do it?
Some code examples are welcome.
THANKS IN ADVANCE.
Mr.Cube
|
|
| Back to top |
|
 |
Eskimo
Joined: 09 Apr 2002 Posts: 35
|
11 Dec 2003 16:38 Re: Watchdog in AT89S8252 ?!? |
|
|
|
|
Sample code
//Refresh macro
#define REFRESH_WATCHDOG() WMCON = WMCON | 0x02
void main()
{
// Init WatchDog
WMCON = WMCON | 0xE0; /* TimeOut Period = 2048ms */
WMCON = WMCON | 0x01; /* Enable WatchDog*/
while (1)
{
//Refreshing
REFRESH_WATCHDOG();
}
}
|
|
| Back to top |
|
 |
C-Man
Joined: 19 Jul 2001 Posts: 1235 Helped: 73
|
11 Dec 2003 16:58 Re: Watchdog in AT89S8252 ?!? |
|
|
|
|
A little tip: do not refresh your watchdog inside an interrupt routine because most of the time interrupts are still running while your main routine has crashed for some obscure reason
Better refresh your watchdog inside a routine which is not called too often or set some flags inside a few routines and only refresh your watchdog (and reset the flags) when all flags are set (this can be done inside your interrupt routine), works much better for me ...
best regards
|
|
| Back to top |
|
 |
mrcube_ns
Joined: 10 Apr 2002 Posts: 429 Helped: 11 Location: Dark side of the Moon
|
12 Dec 2003 23:48 Re: Watchdog in AT89S8252 ?!? |
|
|
|
|
If I understand well you must refresh wd every 2 sec (max), on which xtal?
Mr.Cube
PS. C-man don't you afraid that your uC will restart if some of those flags aren't set ('couse of some conditions or input states)?
|
|
| Back to top |
|
 |
Google AdSense

|
12 Dec 2003 23:48 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
Eskimo
Joined: 09 Apr 2002 Posts: 35
|
13 Dec 2003 1:00 |
|
|
|
|
WD operates from an independent oscillator.
Look at datasheet page 9.
http://www.atmel.com/dyn/resources/prod_documents/doc0401.pdf.
Refresh must be faster then slected period.
|
|
| Back to top |
|
 |