From 598281a1936b94fa583d95cffe077bc791bb369c Mon Sep 17 00:00:00 2001 From: Stefan Rupp Date: Sun, 9 Mar 2014 00:25:02 +0100 Subject: [PATCH] change timer module to run @20Mhz. timebase of 1ms can't be reached perfectly with Timer0 at 20MHz, unfortunatly. --- timer.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/timer.c b/timer.c index 6e15ef6..1ba5e7b 100644 --- a/timer.c +++ b/timer.c @@ -39,16 +39,19 @@ void timer_init(void) timer_time = 0; // - Time accuracy: 1 millisecond (corresponding frequency: 1kHz) - // ==> F_CPU = 2Mhz - // ==> 16Mhz / 64 = 250 kHz - // ==> let timer count to 250 to get 1kHz frequency + // ==> F_CPU = 20Mhz + // ==> 20Mhz / 256 = 78.125 kHz + // ==> let timer count to 78 to get (almost) 1kHz frequency // therefore: - // - Set Timer/Counter0 prescaler to 64 ==> (1< (1< (1<