bigmac wrote:
. . . It is important that the timer interrupt processing be as short as possible . . .
Yes. Especially at 20 kHz.
In my routine, I assumed the conversion was complete (it better be, after 200 microseconds), so I didn't even check the ADC flags. All that I needed to do in the ISR was:
1) Clear the timer interrupt,
2) Read the converted value from the ADC and stuff it in a buffer, and
3) Start the next conversion.
Altogether, the ISR takes under 5 microseconds. If I were sampling at 20 kHz, I would have already used 10% of my cpu bandwidth, without having processed anything yet.