Here is the avr-gcc code I use to periodically read the gyro’s indication around the X-axis.
(4X output is connected to ADC1 and Vref is connected to ADC0)
ISR( TIMER2_COMP_vect )
// ADMUX ^= 1;
ADCSRA |= (1 << ADSC);
while (ADCSRA & (1 << ADSC))
valoare = ADCL + 256 * ADCH;
UART_Transmit_Float( valoare );
I have 2 problems:
- If I uncomment the first line
which means that I would read ADC1 and ADC0 alternatively, then I read a constant value of 395 on ADC0 (aka Vref) and ~392 on ADC1 (aka 4X).
If I leave it commented, which means that I only read ADC1 (aka the 4X output), I get a value of 497 (which soon drops to 492). A huge difference! Why does this happen?
- Why does the reading on ADC1 (aka 4X) change when I rotate the sensor around the Z-axis and Z-axis alone?