summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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.