From 8165b73c801f5a946b093319703f513aa07a7559 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Tue, 19 May 2009 17:58:54 +0200 Subject: * digital/io/src: - fix chrono for the count of match duration. --- digital/io/src/chrono.c | 3 ++- digital/io/src/main_timer.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'digital') diff --git a/digital/io/src/chrono.c b/digital/io/src/chrono.c index 7b9a6936..579ed4bf 100644 --- a/digital/io/src/chrono.c +++ b/digital/io/src/chrono.c @@ -46,8 +46,9 @@ * Number of overflows of the timer/counter 0 to wait before the match is * over. * Basically, it is match_duration / timer_counter_0_overflow_duration. + * Minus one is here for safety reason (because rounding is done at plus one). */ -#define CHRONO_MATCH_OVERFLOW_COUNT (MATCH_DURATION_MS / MT_TC0_PERIOD) +#define CHRONO_MATCH_OVERFLOW_COUNT (MATCH_DURATION_MS / MT_TC0_PERIOD - 1) /** * Duration of a loop to emulate from the original behaviour, in ms. diff --git a/digital/io/src/main_timer.h b/digital/io/src/main_timer.h index 3f582f95..b04c1775 100644 --- a/digital/io/src/main_timer.h +++ b/digital/io/src/main_timer.h @@ -52,7 +52,7 @@ * Period of timer/counter 0 (in millisecond). */ #define MT_TC0_PERIOD \ - (1000 / (AC_FREQ / (MT_TC0_PRESCALER * (MT_TC0_TOP + 1)))) + (1000.0 / (AC_FREQ / (MT_TC0_PRESCALER * (MT_TC0_TOP + 1)))) /** * Initialize the main timer to 4.444 ms. -- cgit v1.2.3