4 or 8 second WDT on ATMEGA 2560 not working

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

Using stidiuo 7 and gcc to program and ATmega2560.

The WDT works fine up to 2 seconds. If I try 4 or 8 it doesn't work.

using library routines:

 

#include <avr/wdt.h>

......

 

 wdt_disable();    

 ENABLE_INTERRUPTS;
 wdt_reset();
 wdt_enable( _BV(WDP2) | _BV(WDP1) | _BV(WDP0) ) ;   // 2 seconds works fine but:   wdt_enable( _BV(WDP3) ) ;   // 4  seconds doesn't work!

 

ideas?

 

 

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

That is not the correct usage of wdt_enable(). I guess you mean:

wdt_enable(WDTO_8S);

EDIT: in particular notice the special handling in:

				"r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) |
						_BV(WDE) | (value & 0x07)) )

 

Last Edited: Thu. Apr 2, 2020 - 02:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks.  Should have check the docs and header files instead of copying someone else's code!!  Duh!!