From 655d773afa02e2589680fa9cefd4302efa2fd2b3 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Wed, 1 May 2013 22:28:02 +0200 Subject: [PATCH] Make jiffies (timer) about 100 Hz. --- projects/step-up/adc.c | 12 +++++++++--- projects/step-up/lights.h | 6 +----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/projects/step-up/adc.c b/projects/step-up/adc.c index fc4c7ca..cff4527 100644 --- a/projects/step-up/adc.c +++ b/projects/step-up/adc.c @@ -12,6 +12,7 @@ volatile static unsigned char current_adc, current_slow_adc; static uint16_t adc_sum, read_zero, drop_count, read_count, n_reads_log; +volatile uint16_t jiffies; static void setup_mux(unsigned char n) { @@ -146,10 +147,15 @@ static void adc1_gain20_adc(uint16_t adcsum) static void inline adc_based_timer() { - static uint16_t pattern_counter; + static unsigned char count; - if (++pattern_counter > 250) { - pattern_counter = 0; + if (++count < 40) // about 100 Hz jiffies + return; + + count = 0; + ++jiffies; + + if ((jiffies & 0x0007) == 0) { patterns_next_tick(); } } diff --git a/projects/step-up/lights.h b/projects/step-up/lights.h index d409d9d..64fce03 100644 --- a/projects/step-up/lights.h +++ b/projects/step-up/lights.h @@ -24,6 +24,7 @@ void inline log_word(uint16_t word) { } /* adc.c */ #define PWMLED_ADC_SHIFT 1 /* 1<<1 measurements per single callback */ +extern volatile uint16_t jiffies; void init_adc(); void susp_adc(); void timer_start_slow_adcs(); @@ -35,11 +36,6 @@ void susp_pwm(); void pwm_off(); void pwm_set(uint8_t stride); -/* tmr.c */ -extern volatile uint16_t jiffies; -void init_tmr(); -void susp_tmr(); - /* pwmled.c */ void init_pwmled(); void pwmled_adc(uint16_t adcval); -- 2.39.3