From cb4e157d626cd01cda40a2957a0b9f449bb5a08e Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Thu, 11 Nov 2010 00:52:14 +1100 Subject: [PATCH] move TICK_TIME to config.h, add TICK_TIME_MS --- config.h.dist | 6 ++++++ timer.c | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.h.dist b/config.h.dist index ffaf896..d0708dc 100644 --- a/config.h.dist +++ b/config.h.dist @@ -341,6 +341,12 @@ struct { */ #define STEP_INTERRUPT_INTERRUPTIBLE 1 +/* + how often we overflow and update our clock; with F_CPU=16MHz, max is < 4.096ms (TICK_TIME = 65535) +*/ +#define TICK_TIME 2 MS +#define TICK_TIME_MS (TICK_TIME / (F_CPU / 1000)) + /* temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop higher values make PID derivative term more stable at the expense of reaction time diff --git a/timer.c b/timer.c index 2390ff0..6ac461d 100644 --- a/timer.c +++ b/timer.c @@ -11,9 +11,6 @@ uint8_t clock_counter_250ms = 0; uint8_t clock_counter_1s = 0; volatile uint8_t clock_flag = 0; -// how often we overflow and update our clock; with F_CPU=16MHz, max is < 4.096ms (TICK_TIME = 65535) -#define TICK_TIME 2 MS - // timer overflow, happens every TICK_TIME ISR(TIMER1_CAPT_vect) { /* @@ -29,7 +26,7 @@ ISR(TIMER1_CAPT_vect) { /* clock stuff */ - clock_counter_10ms += (TICK_TIME / (F_CPU / 1000)); + clock_counter_10ms += TICK_TIME_MS; if (clock_counter_10ms >= 10) { clock_counter_10ms -= 10; clock_flag |= CLOCK_FLAG_10MS;