29
29
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
30
POSSIBILITY OF SUCH DAMAGE. */
32
/* $Id: wdt.h,v 1.9.2.2 2005/01/10 22:44:22 arcanum Exp $ */
32
/* $Id: wdt.h,v 1.22.2.8 2006/09/13 20:41:41 arcanum Exp $ */
35
35
avr/wdt.h - macros for AVR watchdog timer
56
56
\note Depending on the fuse configuration of the particular
57
57
device, further restrictions might apply, in particular it might
58
be disallowed to turn off the watchdog timer. */
58
be disallowed to turn off the watchdog timer.
60
Note that for newer devices (ATmega88 and newer, effectively any
61
AVR that has the option to also generate interrupts), the watchdog
62
timer remains active even after a system reset (except a power-on
63
condition), using the fastest prescaler value (approximately 15
64
ms). It is therefore required to turn off the watchdog early
65
during program startup, the datasheet recommends a sequence like
74
void get_mcusr(void) \
75
__attribute__((naked)) \
76
__attribute__((section(".init3")));
85
Saving the value of MCUSR in \c mcusr_mirror is only needed if the
86
application later wants to examine the reset source, but clearing
87
in particular the watchdog reset flag before disabling the
88
watchdog is required, according to the datasheet.
61
92
\ingroup avr_watchdog
66
97
#define wdt_reset() __asm__ __volatile__ ("wdr")
68
#if defined(__AVR_ATtiny2313__) || defined(__AVR_ATmega48__) \
69
|| defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__)
70
#define _WD_CONTROL_REG WDTCSR
71
#define _WD_PS3_MASK _BV(WDP3)
73
#define _WD_CONTROL_REG WDTCR
74
#define _WD_PS3_MASK 0x00
100
# define _WD_PS3_MASK _BV(WDP3)
102
# define _WD_PS3_MASK 0x00
106
# define _WD_CONTROL_REG WDTCSR
108
# define _WD_CONTROL_REG WDTCR
77
111
#if defined(WDTOE)
84
#if defined (__AVR_ATmega169__) || defined(__AVR_AT90CAN128__) \
118
#if defined(__AVR_AT90CAN128__) \
119
|| defined(__AVR_AT90CAN32__) || defined(__AVR_AT90CAN64__) \
120
|| defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) \
121
|| defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) \
85
122
|| defined(__AVR_ATmega48__) || defined(__AVR_ATmega88__) \
86
|| defined(__AVR_ATmega168__)
123
|| defined(__AVR_ATmega164P__) \
124
|| defined(__AVR_ATmega165__) || defined(__AVR_ATmega165P__) \
125
|| defined(__AVR_ATmega168__) \
126
|| defined(__AVR_ATmega169__) || defined(__AVR_ATmega169P__) \
127
|| defined(__AVR_ATmega324P__) \
128
|| defined(__AVR_ATmega325__) || defined(__AVR_ATmega3250__) \
129
|| defined(__AVR_ATmega329__) || defined(__AVR_ATmega3290__) \
130
|| defined(__AVR_ATmega406__) \
131
|| defined(__AVR_ATmega640__) \
132
|| defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \
133
|| defined(__AVR_ATmega645__) || defined(__AVR_ATmega6450__) \
134
|| defined(__AVR_ATmega649__) || defined(__AVR_ATmega6490__) \
135
|| defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) \
136
|| defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) \
137
|| defined(__AVR_AT90PWM2__) || defined(__AVR_AT90PWM3__)
88
139
#define _wdt_write(value) \
89
140
__asm__ __volatile__ ( \
178
231
a negligible change.
180
233
Possible timeout values are: 15 ms, 30 ms, 60 ms, 120 ms, 250 ms,
181
500 ms, 1 s, 2 s. Symbolic constants are formed by the prefix
234
500 ms, 1 s, 2 s. (Some devices also allow for 4 s and 8 s.)
235
Symbolic constants are formed by the prefix
182
236
\c WDTO_, followed by the time.
184
238
Example that would select a watchdog timer expiry of approximately
217
271
See \c WDT0_15MS */
218
272
#define WDTO_2S 7
220
#if defined(__AVR_ATtiny2313__) || defined(__AVR_ATmega48__) || \
221
defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__)
274
#if defined(__DOXYGEN__) || defined(WDP3)
223
276
/** \ingroup avr_watchdog
225
Note: This is only available on the ATtiny2313, ATmega48, ATmega88,
278
Note: This is only available on the
280
ATtiny24, ATtiny44, ATtiny84,
281
ATtiny25, ATtiny45, ATtiny85,
282
ATtiny261, ATtiny461, ATtiny861,
283
ATmega48, ATmega88, ATmega168,
284
ATmega164P, ATmega324P, ATmega644P, ATmega644,
285
ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561,
288
AT90USB646, AT90USB647, AT90USB1286, AT90USB1287.
228
290
#define WDTO_4S 8
230
292
/** \ingroup avr_watchdog
232
Note: This is only available on the ATtiny2313, ATmega48, ATmega88,
294
Note: This is only available on the
296
ATtiny24, ATtiny44, ATtiny84,
297
ATtiny25, ATtiny45, ATtiny85,
298
ATtiny261, ATtiny461, ATtiny861,
299
ATmega48, ATmega88, ATmega168,
300
ATmega164P, ATmega324P, ATmega644P, ATmega644,
301
ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561,
304
AT90USB646, AT90USB647, AT90USB1286, AT90USB1287.
235
306
#define WDTO_8S 9