Watchdog timer promblem in ATmega32

I am trying to change the watchdog prescalar in an ATmega32 application. The data sheet implies that the watchdog timer registers can be written at time with no special requirements. Is this the case? I am finding that the following code works in AVR Studio but not in the hardware.

void WatchdogInit(void) { WDR(); WDTCSR = 8; // Set prescalar to ~1/4 second timeout. }

Compiler is Imagecraft 7.08.

Any clues.

--
John B
Reply to
John B
Loading thread data ...

In the ATmega162, any change to the watchdog timer, including times, must be preceeded by setting the WDCE (Watchdog Change Enable) bit, wich is the same bit on the ATmega32, where it is called WDTOE (Watchdog Turn Off Enable). I wouldn't be surprised if you have to set this bit on a '32 too before changing the WDT time.

Meindert

Reply to
Meindert Sprang

On 12/10/2006 the venerable Meindert Sprang etched in runes:

Thanks Meindert. In that case, the WDTOE bit seems to be mis-named. I've just looked at the ATmega48 etc. datasheet and it has a code example for setting the watchdog timer which is like the mega162 that you describe. I guess all megas will use the same WDT module so will require the same code.

--
John B
Reply to
John B

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.