Created
February 2, 2015 19:45
-
-
Save DzikuVx/3557a71e508c4a555d55 to your computer and use it in GitHub Desktop.
ATtiny watchdog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//**************************************************************** | |
// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms | |
// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec | |
void setup_watchdog(int ii) { | |
byte bb; | |
int ww; | |
if (ii > 9 ) ii=9; | |
bb=ii & 7; | |
if (ii > 7) bb|= (1<<5); | |
bb|= (1<<WDCE); | |
ww=bb; | |
MCUSR &= ~(1<<WDRF); | |
// start timed sequence | |
WDTCR |= (1<<WDCE) | (1<<WDE); | |
// set new watchdog timeout value | |
WDTCR = bb; | |
WDTCR |= _BV(WDIE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment