From: Leo C Date: Fri, 15 Apr 2016 15:26:42 +0000 (+0200) Subject: Use timer 4 instead of 3 for systick (1ms). X-Git-Tag: hexrel-6.6~4 X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/commitdiff_plain/5730789084d22d229a87fa42fe55079c4bb35cd8 Use timer 4 instead of 3 for systick (1ms). --- diff --git a/avr/main.c b/avr/main.c index 2199454..0a1cab6 100644 --- a/avr/main.c +++ b/avr/main.c @@ -115,10 +115,10 @@ void setup_avr(void) CLKPR = 0; /* Timer */ - PRR1 &= ~_BV(PRTIM3); - OCR3A = F_CPU / 1000 - 1; /* Timer3: 1000Hz interval (OC3A) */ - TCCR3B = (0b01< * - * SPDX-License-Identifier: GPL-2.0+ + * SPDX-License-Identifier: GPL-2.0 */ -#include "common.h" +#include "timer.h" #include #include #include "time.h" -#include "timer.h" /* timer interrupt/overflow counter */ /* counts up every ms. */ @@ -16,9 +15,9 @@ static volatile uint32_t timestamp; /* - * 1000Hz timer interrupt generated by OC3A + * 1000Hz timer interrupt generated by OC4A */ -ISR(TIMER3_COMPA_vect) +ISR(TIMER4_COMPA_vect) { static int_fast8_t tick_10ms; static int_fast8_t tick_1s; @@ -26,6 +25,8 @@ ISR(TIMER3_COMPA_vect) extern void disk_timerproc(void); + OCR4A += F_CPU / 1000; /* 1000Hz interval */ + timestamp++; i = tick_10ms + 1; @@ -47,24 +48,6 @@ ISR(TIMER3_COMPA_vect) } -/*--------------------------------------------------------------------------*/ - -#if 0 -void timer_setup(void) -{ - - /* Clock */ - CLKPR = _BV(CLKPCE); - CLKPR = 0; - - /* Timer */ - - OCR1A = F_CPU / 1000 - 1; // Timer1: 1000Hz interval (OC1A) - TCCR1B = 0b00001001; - TIMSK1 = _BV(OCIE1A); // Enable TC1.oca interrupt -} -#endif - /*--------------------------------------------------------------------------*/ uint32_t get_timer(uint32_t base) diff --git a/include/timer.h b/include/timer.h index c6d6053..83bc329 100644 --- a/include/timer.h +++ b/include/timer.h @@ -7,6 +7,8 @@ #ifndef TIMER_H #define TIMER_H +#include "common.h" + uint32_t get_timer(uint32_t); #endif /* TIMER_H */