Watchdog and Atmega2560

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
rradojko
Posts: 40
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Watchdog and Atmega2560

Post by rradojko »

Hello!

Using ATmega2560 processor.
How to use a watchdog?

Enable watchdog

Code: Select all

MCUSR = 0x08;
Is that right?

Disable watchdog

Code: Select all

wdt_disable();
Is that right?

Reset watch dog

Code: Select all

wdt_reset();
Is that right?

I wonder whether the commands are correct for the watchdog?

Thanks for the reply.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Watchdog and Atmega2560

Post by dazz »

Hi
i think the WDT enable is as follows

Code: Select all

wdt_enable(WDTO_500MS);
this part of the code below sets the WDT period to 500ms, set it to what you want upto i believe 2seconds which would be (WDTO_2S)

Code: Select all

(WDTO_500MS)
I dont tend to use WDT so havent tested the above
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Watchdog and Atmega2560

Post by dazz »

Hi
i think the WDT enable is as follows

wdt_enable(WDTO_500MS);

this part of the code below sets the WDT period to 500ms, set it to what you want upto i believe 2seconds which would be (WDTO_2S)

(WDTO_500MS)

I dont tend to use WDT so havent tested the above
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

rradojko
Posts: 40
Joined: Thu Jun 21, 2012 8:53 am
Has thanked: 10 times
Been thanked: 2 times
Contact:

Re: Watchdog and Atmega2560

Post by rradojko »

Hello dazz!

Thank you very much for the answer.

I tested the code on AVR atmega32...

Code: Select all

wdt_enable(WDTO_2S);
This code works, very good :D ...

Also code for the reset WD works...

Code: Select all

wdt_reset();
Thanks dazz again for the information.

I have another question.
I use procesr ATmega2560 (http://www.atmel.com/Images/doc2549.pdf).
Watchdog has a choice -->>
1:Interrupt
2:System reset
3:Interrup and syistem reset

What would be the code for watchdog the Syistem reset?

Thanks!
rradojko
Attachments
WD-Atmega2560
WD-Atmega2560
WD.JPG (44.02 KiB) Viewed 4482 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Watchdog and Atmega2560

Post by dazz »

Hi
If you enable watchdog always on in the config, then the 2560 defaults to the mode you require.

make sure you include a couple of resets to make sure the counter doesnt run over wdt_reset()

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Post Reply