Can you explain this line?
ADCSRB &= ~(7 << ADTS0);
What is the result in ADCSRB register?
What for this line is used?
Take it step by step.
ADCSRB &= ~(7 << ADTS0);
What is the value of ADTS0?
Hint: it's a value between 0 and 7.
Now shift 0b111 left by that number of places
Invert that value.
Now bitwise AND that with whatever value is already in ADCSRB
It resets the ADTS field of the ADCSRB register to zero. The ADTS field selects the auto-trigger source for the ADC. See datasheet section 26.8.5.
The idiom "reg &= ~ field" clears a field to zero, basically its bit-wise AND-NOT. This allows one field in a register to be reset without affecting any other fields.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.