Date:2012-06-21 21:15:56 (7 years 7 months ago)
Author:Werner Almesberger
Commit:58e0dda95d89dc652422961e6f5b823b41a86175
Message:fw/accel.c: use timer 0 to trigger a pair of conversions (X/Y) only every 1 ms

Files: fw/accel.c (2 diffs)

Change Details

fw/accel.c
5454    if (sample)
5555        sample(chan_x, v);
5656
57    chan_x = !chan_x;
58    admux(chan_x);
57    if (chan_x) {
58        chan_x = 0;
59        admux(0);
60        adcsra(1);
61    }
62}
63
64
65ISR(TIMER0_OVF_vect)
66{
67    chan_x = 1;
68    admux(1);
5969    adcsra(1);
6070}
6171
...... 
6373void accel_start(void)
6474{
6575    adcsra(0);
66    admux(1);
67    chan_x = 1;
76
77    TCNT0 = 0;
78    OCR0A = 125; /* 8 MHz/64/125 = 1 kHz */
79    TCCR0A =
80        1 << WGM01 | /* WG Mode 7 (Fast PWM to OCR0A) */
81        1 << WGM00;
82    TCCR0B =
83        1 << WGM02 | /* WG Mode 7, continued */
84        1 << CS01 | /* clkIO/64 */
85        1 << CS00;
86    TIMSK0 = 1 << TOIE0; /* interrupt on overflow */
6887}

Archive Download the corresponding diff file

Branches:
master
tornado-v1



interactive