How to use a Watch Dog Timer?

Status
Not open for further replies.

hameeds01

Advanced Member level 2
Joined
Aug 23, 2005
Messages
599
Helped
75
Reputation
156
Reaction score
41
Trophy points
1,308
Location
Islamabad Pakistan
Activity points
4,540
How to use a Watch Dog Timer? Am I using the WDT in a correct way?? I need a sample code for wdt in CCS C ……
Its not working only it performs task2 :|

#include <16F877A.h>
#fuses XT,WDT,PUT,BROWNOUT,NOPROTECT,NOLVP,NOCPD
#use delay(clock=4000000, RESTART_WDT)

timer0_ISR
{
restart_wdt()
task1()
}

main()
{
setup_wdt(WDT_18MS)
while(true)
{
restart_wdt()
task2()
}
}
 

Re: WDT help???

You'll never reset a wdt in an isr as it's possible that the program hangs while the timer interrupt is still running.
Reset the wdt at different locations in your application.
 

Re: WDT help???

Whatz the relationship b/w timer0 &wdt? If I enable wdt then timer0 runs very fast but it runs fine when I disable wdt ????
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…