From 9e4b0bd113549ccc190a1379deab31670b12415f Mon Sep 17 00:00:00 2001 From: HUB Date: Sat, 15 Dec 2012 01:14:55 +0400 Subject: [PATCH] Corrected timer seed Prevoius one caused the clock being slow. If timer is se to "2", the diagram looks like this: value: __|_____|_____|_____|__ 0 1 2 3 interrupt: __+-+_________+-+______ 3 intervals are between interrupts. So interrupts happen (OCR1A+1) more rare than clock cicles. Frequency is (OCR1A+1) times lower than quarz clocking --- arduino_clock.ino | 2 +- clock_scale.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino_clock.ino b/arduino_clock.ino index 02ab011..c3a7419 100644 --- a/arduino_clock.ino +++ b/arduino_clock.ino @@ -2,7 +2,7 @@ #include #include //this is a must -#define TIMER_SEED 15633 +#define TIMER_SEED 15632 SerialLCD slcd(11, 12); //this is a must, assign soft serial pins byte seconds = 0; diff --git a/clock_scale.py b/clock_scale.py index df8256c..292f1d2 100644 --- a/clock_scale.py +++ b/clock_scale.py @@ -42,7 +42,7 @@ def better_result(cur_skew, for conter_seed in xrange(1,timer_max_value): for p in prescalers: - postscaler = freq / p / (conter_seed) + postscaler = freq / p / (conter_seed + 1) if postscaler > max_postscaler: continue skew = postscaler - int(postscaler) if better_result(skew,