movie_freak
Member level 5
using avr watchdog
Hi,
I've tried something like this:
What i am trying to do:
initial values of watch_dog_mili =1500; watch_dog_F =0;watch_dog_counter=10;
set the watchdog timeout to ~ 2secs
calling wdt_reset every 1500ms in interrupt
In the mean time calling RST_WATCH_DOG() in main to check the software hang in every 10*1500 =15secs..
In my code there are no routines which take more than 10secs..still the watchdog resets the controller as soon as it is initialized..
So need help in this regard
Surya
Hi,
I've tried something like this:
Code:
Code:
void WATCH_DOG_INIT(void)
{
watch_dog_F =1;
// Start timed equence
WDTCR |= (1<<WDCE) | (1<<WDE);
// Set new prescaler(time-out)
WDTCR = (1<<WDE) | (1<<WDP2) | (1<<WDP1)|(1<<WDP0) |(0<<WDCE);
}
void RSET_WATCH_DOG(void)
{
wdt_reset(); // reset watch dog
watch_dog_counter = 10;
}
ISR() // 1ms isr
{
if(watch_dog_F ==1)
{
watch_dog_mili--;
if(watch_dog_mili==0)
{
watch_dog_mili=1500;
if(watch_dog_counter > 0)
{
watch_dog_counter--;
wdt_reset();
}
}
}
}
int main(void)
{
WATCH_DOG_INIT();
while(1)
{
/* Some work done over here */
RSET_WATCH_DOG();
}
}
What i am trying to do:
initial values of watch_dog_mili =1500; watch_dog_F =0;watch_dog_counter=10;
set the watchdog timeout to ~ 2secs
calling wdt_reset every 1500ms in interrupt
In the mean time calling RST_WATCH_DOG() in main to check the software hang in every 10*1500 =15secs..
In my code there are no routines which take more than 10secs..still the watchdog resets the controller as soon as it is initialized..
So need help in this regard
Surya