refactor logger
[simavr] / tests / atmega48_enabled_timer.c
1 /*
2  * avrtest.c
3  *
4  * Created on: 4 Feb 2011
5  * Author: sliedes
6  * This is a very slightly modified version of atmega48_disabled_timer.c
7  * by jone.
8  */
9
10 #include <avr/io.h>
11 #include <avr/interrupt.h>
12 #include <avr/sleep.h>
13
14 #include "avr_mcu_section.h"
15 AVR_MCU(F_CPU, "atmega48");
16
17 ISR(TIMER0_COMPA_vect)
18 {
19 }
20
21 int main(void)
22 {
23         // Set up timer0 - do not start yet
24         TCCR0A |= (1 << WGM01);                     // Configure timer 0 for CTC mode
25         TIMSK0 |= (1 << OCIE0A);                    // Enable CTC interrupt
26         OCR0A   = 0xAA;                             // CTC compare value
27
28         TCCR0B |= (1 << CS00) | (1 << CS01);        // Start timer: clk/64
29
30         sei();                                      // Enable global interrupts
31
32         // here the interupts are enabled, but the interupt
33         // vector should not be called
34         sleep_mode();
35
36         // this should not be reached
37         cli();
38         sleep_mode();
39 }