summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Dufour2009-05-19 17:58:54 +0200
committerJérémy Dufour2009-05-19 17:58:54 +0200
commit8165b73c801f5a946b093319703f513aa07a7559 (patch)
tree1fa894c42965430587bedcf22999e0a843b6057d
parent1a48d1ffd069b227656779553cd85c75f8d6fa29 (diff)
* digital/io/src:
- fix chrono for the count of match duration.
-rw-r--r--digital/io/src/chrono.c3
-rw-r--r--digital/io/src/main_timer.h2
2 files changed, 3 insertions, 2 deletions
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.