2 attiny13_watchdog_test.c
4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
25 #include <avr/interrupt.h>
26 #include <avr/delay.h>
27 #include <avr/sleep.h>
31 * This demonstrate how to use the avr_mcu_section.h file
32 * The macro adds a section to the ELF file with useful
33 * information for the simulator
35 #include "avr_mcu_section.h"
36 AVR_MCU(F_CPU, "atmega48");
38 static int uart_putchar(char c, FILE *stream) {
40 uart_putchar('\r', stream);
41 loop_until_bit_is_set(UCSR0A, UDRE0);
46 static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
52 // nothing to do here, we're just here to wake the CPU
59 wdt_enable(WDTO_120MS);
61 // enable watchdog interupt
62 // NOTE: since the Change Enable bit is no longer on, it should not
63 // change the timer value that is already set!
68 printf("Watchdog is active\n");
74 printf("Waiting for Watchdog to kick\n");
75 // now , stop calling the watchdog reset, and just sleep until it fires
77 printf("Watchdog kicked us!\n");
79 // when arriving here, the watchdog timer interupt was called and woke up
80 // the core from sleep, so we can just quit properly