Watchdog doesn't Reset on Mega32

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

Hi everybody,

I'm havin a problem with the watchdog on a mega 32.

I've set the WDTCR to 0x0F, which means watchdog enabled and timeout is about 2 seconds. Haven't implemented the WDR insruction jet expecting that the chip is reset after 2 seconds, restarting the program.

But nothing happens, the program runs fine as it should. (interrupts are enabled)

is there anything else to do ?

greetings, Harald.

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

Please show us your WDTCR setup code. There is a timed sequence that must be observed when setting WDTCR if memory serves correctly.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

in CV it's just one line:

WDTCR=0x0F ;

the listfile show this:

code

; 673
; 674 // Watchdog Timer initialization
; 675 // Watchdog Timer Prescaler: OSC/2048k
; 676 WDTCR=0x0F;
0004e5 e0ef LDI R30,LOW(15)
0004e6 bde1 OUT 0x21,R30
; 677
; 678
/code

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

I think, that the timed sequence is needed only when disabling the Watchdog, that's what the datasheet tells... ?

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

I think this might be another gotcha... try following the 'timed' sequence, as you are not only enabling the watchdog, but you are also changing the prescaler. I remember that a few years back I had a similar issue, but I don't remember the solution. Though that may be whay I always use the timed sequence now, it's how I have it implemented in my libraries.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.