diff options
Diffstat (limited to 'avr/timer.c')
-rw-r--r-- | avr/timer.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/avr/timer.c b/avr/timer.c index 1b15985..03c86c8 100644 --- a/avr/timer.c +++ b/avr/timer.c @@ -47,6 +47,15 @@ ISR(TIMER4_COMPA_vect) tick_10ms = i; } +/*--------------------------------------------------------------------------*/ + +void setup_timer(void) +{ + PRR1 &= ~_BV(PRTIM4); + OCR4A = F_CPU / 1000 - 1; /* Timer4: 1000Hz interval */ + TCCR4B = (0b00<<WGM42)|(0b001<<CS40); /* Normal Mode, Prescaler 1 */ + TIMSK4 = _BV(OCIE4A); /* Enable Output Compare A interrupt */ +} /*--------------------------------------------------------------------------*/ |