From 5d550a0121821da062b8d9cdc7a876b87540c58e Mon Sep 17 00:00:00 2001 From: mb Date: Wed, 4 Apr 2018 11:51:21 +0200 Subject: [PATCH] Fixed timer.c and timer.h. --- sketches/pendulum/timer.c | 9 +++++---- sketches/pendulum/timer.h | 5 +++-- sketches/pendulum/timer_macros.h | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sketches/pendulum/timer.c b/sketches/pendulum/timer.c index ff51073..cb9e611 100644 --- a/sketches/pendulum/timer.c +++ b/sketches/pendulum/timer.c @@ -31,10 +31,11 @@ void timer_reset(void) highBits64 = 0; } -ISR(TIMER1_OVF_vect) +// ISR(TIMER1_OVF_vect) +void timer_overflow(void) { - highBits32 += 0x01 00 00 00; - highBits64 += 0x00 00 00 00 01 00 00 00; + highBits32 += 0x01000000; + highBits64 += 0x0000000001000000; } uint32_t timer_now32(void) @@ -49,4 +50,4 @@ uint64_t timer_now64(void) uint64_t lowBits = TCNT0; uint64_t middleBits = TCNT1; return highBits64 | (middleBits<<8) | lowBits; -} \ No newline at end of file +} diff --git a/sketches/pendulum/timer.h b/sketches/pendulum/timer.h index 62df5ec..44a7816 100644 --- a/sketches/pendulum/timer.h +++ b/sketches/pendulum/timer.h @@ -7,8 +7,9 @@ void timer_init(void); void timer_reset(void); +void timer_overflow(void); -ISR(TIMER1_OVF_vect); +// ISR(TIMER1_OVF_vect); uint32_t timer_now32(void); uint64_t timer_now64(void); @@ -19,4 +20,4 @@ uint64_t timer_now64(void); uint32_t volatile highBits32; // max: ~214.7483648s uint64_t volatile highBits64; // max: ~29247a -#endif \ No newline at end of file +#endif diff --git a/sketches/pendulum/timer_macros.h b/sketches/pendulum/timer_macros.h index 6471a1b..bd3abcf 100644 --- a/sketches/pendulum/timer_macros.h +++ b/sketches/pendulum/timer_macros.h @@ -19,7 +19,7 @@ | TCCRnA_COMnB_toggle \ | TCCRnA_COMnB_low \ | TCCRnA_COMnB_high ) - +#define TCCRnB_CSn_CLEAR ~ 0x07 // Timer/CounterN Interrupt Mask Register #define TIMSKn_ENABLE_INTERRUPT_on_nothing 0x00 #define TIMSKn_ENABLE_INTERRUPT_on_overflow 0x01 @@ -120,4 +120,4 @@ #define TIMSK2_ENABLE_INTERRUPT_on_compare_match_A 0x02 #define TIMSK2_ENABLE_INTERRUPT_on_compare_match_B 0x04 -#endif \ No newline at end of file +#endif