I am using an ATTINY44 in my current project.
As I need to do some time sensitive switching I would like to avoid any unnecessary delay.
To control another device (not time sensitive) I need to read an analog value though.
I read several examples (including I checked below code from the Arduino cores (for
analogRead()) and most are setting the ADSC bit and then waiting with a while loop for the conversion to finish.
I also read about the free running mode in the datasheet and noise reduction mode (conversion during idle time).
So now my questions:
Is this while loop just bad coding or are they doing it for noise reduction (because in free running mode, also other code would be executed during conversion)?
If I put the check for ADSC to be cleared in my main loop, what would be the advantaged / disadvantages?
If this method is for for noise reduction, how much added inaccuracy (maybe a ballpark figure) can I expect - I can live with +-2 or 3LSB?
Code from wiring_analog.c:
// start the conversion sbi(ADCSRA, ADSC); // ADSC is cleared when the conversion finishes while (bit_is_set(ADCSRA, ADSC));