watchdog interrupt atmega644 not working

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I try to use a watchdog to get interrupts, no reset,
but it is not working at all.

My code to initialize:

void wd_start(void)
{
wdt_reset();
MCUSR &= ~(1<<WDRF);
WDTCSR |= (1<<WDCE) | (1<<WDE); //needed by manual p 50
WDTCSR = 68; // = WDIE=1, WDP2=1, WDE=0 (no reset)
return;
}

There is no effect, but if I use
wdt_enable(WDTO_120MS) (from wdt.h (WinAVR-gcc)
is it working.
However I can't use wdt.h, because I have to set WDIE and to clear WDE in order to get interrupts and this is not possible in wdt.h

What is wrong in my code?
How can I configure the atmega 644 to get interrupts?

Thank in advance
BMW freak

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What is wrong in my code?
Are you enabling interrupts??

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WDTON fuse is unprogrammed?
Compiler optimizations are enabled, so the generated code fulfills the timing requirements?

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

but it is not working at all

How are you determining that? If you say "simulator" then take a peek at the manual - there's every chance it does not simulate the watchdog interrupt mechanism correctly (though sim2 is likely to be better than sim1 and it probably support 644P)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's an alternate to wdt.h with irq modes support-
http://www.mtcnet.net/~henryvm/wdt/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
Quote:
What is wrong in my code?
Are you enabling interrupts??

Not yet, but after your post did I insert sei(),
and it works! Wunderbar!

Many thanks from the old Europe (without any Edelweiß too)

BMWfreak

Last Edited: Wed. Jun 17, 2009 - 09:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

curtvm wrote:
Here's an alternate to wdt.h with irq modes support-
http://www.mtcnet.net/~henryvm/wdt/

It seems to be very useful, I will try it,
thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sternst wrote:
WDTON fuse is unprogrammed?
Compiler optimizations are enabled, so the generated code fulfills the timing requirements?

The compiler optmiziation is unchanged from my "normal" mode. For a short time I was thinking, the compiler could manipulate the code for not fulfilling the 4-cycle-condition.
But the function after inserting sei(); is a compiler rehabitation.

many tx
bmwfreak

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sternst wrote:
WDTON fuse is unprogrammed?
Compiler optimizations are enabled, so the generated code fulfills the timing requirements?

The compiler optmiziation is unchanged from my "normal" mode. For a short time I was thinking, the compiler could manipulate the code for not fulfilling the 4-cycle-condition.
But the function after inserting sei(); is a compiler rehabitation.

many tx
bmwfreak

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
Quote:
What is wrong in my code?
Are you enabling interrupts??

Not yet, but after your post did I insert sei(),
and it works! Wunderbar!

Many thanks from the old Europe (wihtout Edelweiß too)

BMWfreak

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Quote:

but it is not working at all

How are you determining that? If you say "simulator" then take a peek at the manual - there's every chance it does not simulate the watchdog interrupt mechanism correctly (though sim2 is likely to be better than sim1 and it probably support 644P)

I did not simulate it. In the program are markers so I can see where the program is.

BMWfreak