diff options
author | Leo C | 2018-09-08 20:29:11 +0200 |
---|---|---|
committer | Leo C | 2018-09-08 20:29:11 +0200 |
commit | 89826c563e38a30d5bfc589905eb1202fa14b751 (patch) | |
tree | dd078beac30e6433c2c7697dca0fb7387d7e14fd /avr/timer.c | |
parent | 226d32211880a061265faf6b8eadaf6ca1ec7a38 (diff) | |
download | z180-stamp-89826c563e38a30d5bfc589905eb1202fa14b751.zip |
move sys timer setup from main to timer.c
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 */ +} /*--------------------------------------------------------------------------*/ |