user7734: I was modifying this ADC Touch implementation, namely switching analogRead and pinMode to what I thought would be port manipulation equivalents.
I get very different readings (better and more stable in my case).
So, what I think is equivalent is actually quite different. Can someone point the differences to me?
Original:
    pinMode(ADCChannel, INPUT_PULLUP);

    ADMUX |=   0b11111;
    ADCSRA |= (1<<ADSC); //start conversion
    while(!(ADCSRA & (1<<ADIF))); //wait for conversion to finish
    ADCSRA |= (1<<ADIF); //reset the flag

    pinMode(ADCChannel, INPUT);
    _value += analogRead(ADCChannel);

Modified:
    DDRC &= ~(1 << ADCChannel);
    PORTC |= (1 << ADCChannel);

    ADMUX |=   0b11111;
    ADCSRA |= (1<<ADSC); //start conversion
    while(!(ADCSRA & (1<<ADIF))); //wait for conversion to finish
    ADCSRA |= (1<<ADIF); //reset the flag

    DDRC &= ~(1 << ADCChannel);
    _value += analogRead(ADCChannel);


user368: Your modified code doesn't disable the pullup on the pin.
PORTC &= ~_BV(ADCChannel);


7734: <p>I was modifying <a href="https://github.com/martin2250/ADCTouch" rel="nofollow">this</a> ADC Touch implementation, namely switching <em>analogRead</em> and <em>pinMode</em> to what I thought would be port manipulation equivalents.</p>

<p>I get very different readings (better and more stable in my case).</p>

<p>So, what I think is equivalent is actually quite different. Can someone point the differences to me?</p>

<p>Original:</p>

<pre><code>    pinMode(ADCChannel, INPUT_PULLUP);

    ADMUX |=   0b11111;
    ADCSRA |= (1&lt;&lt;ADSC); //start conversion
    while(!(ADCSRA &amp; (1&lt;&lt;ADIF))); //wait for conversion to finish
    ADCSRA |= (1&lt;&lt;ADIF); //reset the flag

    pinMode(ADCChannel, INPUT);
    _value += analogRead(ADCChannel);
</code></pre>

<p>Modified:</p>

<pre><code>    DDRC &amp;= ~(1 &lt;&lt; ADCChannel);
    PORTC |= (1 &lt;&lt; ADCChannel);

    ADMUX |=   0b11111;
    ADCSRA |= (1&lt;&lt;ADSC); //start conversion
    while(!(ADCSRA &amp; (1&lt;&lt;ADIF))); //wait for conversion to finish
    ADCSRA |= (1&lt;&lt;ADIF); //reset the flag

    DDRC &amp;= ~(1 &lt;&lt; ADCChannel);
    _value += analogRead(ADCChannel);
</code></pre>
 368: <p>Your modified code doesn't disable the pullup on the pin.</p>

<pre><code>PORTC &amp;= ~_BV(ADCChannel);
</code></pre>
