Grumpy_Mike:
But they are.
Not if you are using the ADC Auto Trigger Source (ADTS2:0) bits in ADCSRB to trigger the ADC. You need no ISR and no Interrupt. Options are OCR0A, Timer0 Overflow, OCR1B, Timer1 Overflow, and Timer1 Capture Event.
Now you would probably want to use the ADC Conversion Complete Interrupt to save the value and set the timer to trigger another read later. Since that processing is not time-critical, it doesn't matter if it is deferred a few microseconds by another interrupt.
Grumpy_Mike:
And I want to tell you that is rubbish.
Of course the OP is right and the only reasonable way to get a jitter-free sampling is using autotriggering. Disabling interrupts only reduces possible jitter, not eliminate it.
Smajdalf:
Of course the OP is right and the only reasonable way to get a jitter-free sampling is using autotriggering.
Ok, now how do I go about configuring the auto trigger source of the ADC to use Timer/Counter0 compare match A. Because I can only get Timer/Counter0 overflow to trigger it and that's not useful to me. Right now this is the main issue I have.
You need to clear the output compare interrupt flag, either by enabling the interrupt or when you collect the ADC result. The ADC is triggered only when the corresponding source flag goes from 0 to 1.
There's one issue that to my surprise has not been addressed yet: the time it takes to take an analog reading: this is about 110µs, making your timing of taking samples at 0, 70 µs, 125µs impossible - unless you set more registers to change the ADC clock and make the sampling faster (you will lose accuracy if you go too far in this).
A second possible issue: the settling time of the ADC itself. The moment you switch ADC channels (this happens the moment you try to read a new channel) the built-in sampling cap needs time to settle. It is common practice to take two readings, discarding the first one, to prevent crosstalk between channels. If your signal has a very low output impedance (<<10k) this is probably not an issue.
Using timer interrupts to run your process is a sound concept, for µs accuracy you indeed have to be really careful on what other processes are running in the Arduino environment (like indeed the millis and micros timers). After all it's only 16 clock ticks per µs at 16 MHz!
Smajdalf:
You need to clear the output compare interrupt flag, either by enabling the interrupt or when you collect the ADC result. The ADC is triggered only when the corresponding source flag goes from 0 to 1.
This is what I was missing! Now it's working great. A huge thank you for helping me out!