Lively Coding Badly!
Which you haven't done. You need to save+disable interrupts before mucking with the WDT configuration and restore interrupts afterwards.
so I will code it thusly:
cli(); //disable global interrupts
MCUSR = 0x00; //clear all reset flags
//set WD_ChangeEnable and WD_resetEnable to alter the register
WDTCSR |= (1<<WDCE) | (1<<WDE); // this is a timed sequence to protect WDTCSR
// set new watchdog timeout value to 1024K cycles (~8.0 sec)
WDTCSR = (1<<WDP3) | (1<<WDP0);
//enable watchdog interrupt
WDTCSR |= (1<<WDIE);
sei(); //enable global interrupts
Thankyou: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1197886952
also: http://www.arduino.cc/playground/Main/AVR Thankyou, theGoogle
By my testing, a digital input is the worst choice. Without a pull-up (or pull-down) resistor, the input can (and does) float.
Very well. In order to keep to the Port Manipulation theme:
DDRB = 0x00; // set ports to intput to save power
DDRD = 0x00; // set ports to intput to save power
PORTB = 0xFF; // enable pullups on portB
PORTC = 0xFF; // enable pullups on portC
PORTD = 0xFF; // enable pullups on portD
variation on this post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1243235304/5
if setting the ports equal to 0x00 does not turn off the internal pullups, i will use a better method on wake from sleep.
edit< no better method http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1277985118/15
Regarding my question about peripherals: maintaining their values, and shutting down their clocks, you said
This is definately not necessary. Power Down Sleep shuts off ALL clocks.
The PRR register description (9.11.3 in Atmel DS) recommends that the fuses be kept track of if you're shutting them down. I'm happy if the clocks get turned off. (had some question about the TWI clock, because there is a TWI address recognition wake cue, but it looks like you're right about all the generated clocks getting shut down.) I'll play with the peripheral fuse settings and run my I2C Digital Potentiometer (MCP4551) to see if I get a crash.
CHEERS!
Joel
"...you are at Liberty to communicate this Paper to whom you please;
it being of more Importance that Knowledge should increase,
than that your Friend should be thought an accurate Philosopher"
-Ben Franklin