Rev 219 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 219 | Rev 224 | ||
|---|---|---|---|
| Line 42... | Line 42... | ||
| 42 | * enabled, but global interrupts need to be enabled by the application. |
42 | * enabled, but global interrupts need to be enabled by the application. |
| 43 | */ |
43 | */ |
| 44 | void Timebase_Init() { |
44 | void Timebase_Init() { |
| 45 | 45 | ||
| 46 | #if defined(__AVR_ATmega8__) |
46 | #if defined(__AVR_ATmega8__) |
| 47 | #if TIMEBASE_PRESCALE |
47 | #if TIMEBASE_PRESCALE == 64 |
| 48 | TCCR0 = (1<<CS01) | (1<<CS00); // prescaler: 64 |
48 | TCCR0 = (1<<CS01) | (1<<CS00); // prescaler: 64 |
| 49 | #elif TIMEBASE_PRESCALE |
49 | #elif TIMEBASE_PRESCALE == 256 |
| 50 | TCCR0 = (1<<CS02); // prescaler: 256 |
50 | TCCR0 = (1<<CS02); // prescaler: 256 |
| 51 | #endif |
51 | #endif |
| 52 | TCNT0 = TIMEBASE_RELOAD; // set initial reload-value |
52 | TCNT0 = TIMEBASE_RELOAD; // set initial reload-value |
| 53 | TIFR |= (1<<TOV0); // clear overflow int. |
53 | TIFR |= (1<<TOV0); // clear overflow int. |
| 54 | TIMSK |= (1<<TOIE0); // enable overflow-interrupt |
54 | TIMSK |= (1<<TOIE0); // enable overflow-interrupt |