I am looking at this for a few hours now and I simply can't see why this setup does not result in free running ADC. I'm on attiny85.
void setup_adc() { // Init ADCSRA and B ADCSRA = 0; ADCSRB = 0; // Set ADC to do 8 bit resolution (left align and we will only use ADCH) sbi(ADMUX, ADLAR); // Set PB2 (ADC1) as input sbi(ADMUX, MUX0); // Disable digital input on PB2, we will only need it for ADC sbi(DIDR0, ADC1D); // Perform clk/128 conversions per second (which is more than enough) sbi3(ADCSRA, ADPS0, ADPS1, ADPS2); // Choose pin change interrupt as ADC trigger //sbi2(ADCSRB, ADTS1, ADTS2); Free running for now // Finally enable auto-trigger, conversion complete interrupt and ADC as a whole sbi3(ADCSRA, ADATE, ADIE, ADEN); }
I'm not getting any calls to the ADC complete interrupt handler:
ISR(ADC_vect) { adcData = ADCH; adcDataAvailable = 1; }
I am already using PWM on timer 0 and 1 (for some reason PWM on timer 1 does not seem to run without start PWM on timer 0).
Anyway, my question is whether anyone can see what I am missing in my setup ? I'm clueless. Tried different examples. Setting ADCSRA and B to 0 is the result of being desperate, that shouldn't be necessary, right ?
Many thanks,
Henk
PS: I do start a first conversion:
setup_pwm(); setup_adc(); // Turn on Pin Change interrupt //sbi(GIMSK, PCIE); // Enable external interrupt on PB2 //sbi(PCMSK, PCINT2); //clearNote(); // Start conversion sbi(ADCSRA, ADSC); sei();