Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Watchdog in AT89S8252 ?!?

Status
Not open for further replies.

mrcube_ns

Advanced Member level 1
Joined
Apr 10, 2002
Messages
452
Helped
48
Reputation
96
Reaction score
34
Trophy points
1,308
Location
Europe
Activity points
3,813
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
 

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();
}
}
 

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
 

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)?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top