Go Down

Topic: Arduino Nano - A6/A7 internal pull-up resistors (Read 42291 times) previous topic - next topic

dadaumpa

Hello,

this is not mentioned anywhere in the documentation as far as I can see.

The question is: do the 2 extra analog pins (A6 and A7), which are found on the Arduino Nano and similar boards, have internal pull-ups?

I had a look at the ATmega datasheet, and it makes no mention of pull-ups for the two corresponding pins (ADC6 and ADC7, cfr. paragraph 1.1.9). It explicitly says, however, regarding the other pins (cfr. paragraphs 1.1.3, 1.1.4, 1.1.6) that they are "bi-directional I/O port with internal pull-up resistors".

So my guess is that there are no internal pull-up resistors for ADC6 and ADC7. Google also reports this explicitly mentioned on some AVR forum (http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=89804&start=0).

Is this true? Otherwise I must conclude that my board is faulty :-)

If this is the case, BTW, it would be nice to add this information on the Arduino Nano page, in order to spare some possible headache to other hobbists...

Some background and context: I'm using the analog pins to read an array of buttons, similar to what described here: http://arduino.cc/forum/index.php/topic,20125.0.html.

To keep the circuitry at a minimum, I turn on the internal pull-up by using:

Code: [Select]
  pinMode(A6, INPUT);
  digitalWrite(A6, HIGH);


The trick worked so far with A0 and A5, but it doesn't with A6. I'm getting wildly fluctuating readings with no buttons pressed, which suggests the internal pull-up is either broken or... simply non-existant :-)

cheers,
Aldo




cmiyc

A6 and A7 are only inputs available to the mux in front of the ADC.  There is no digital hardware behind the pins.

Since the pull up is part of the digital latch, those two pins dont have pull ups (nor do they work as digital inputs.)

Not that it is affecting your code, keep in mind that pinMode() has no effect on analog pins.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

dadaumpa

Thanks for the explanation. Makes sense, just wasn't so obvious for a newbie like me :-)

Regarding pinMode(), that's curious. You mean it has no effect on A6/A7 because of their analog, input-only nature?

Because the page http://arduino.cc/en/Tutorial/AnalogInputPins actually uses pinMode() on an analog pin. Ok, that's obviously to set it as OUTPUT. INPUT should be redundant, since they are input by default. But I thought it was a good measure to set them to INPUT, just in case some code previously had set them in OUTPUT mode...

cheers,
Aldo

Steph

Regarding pinMode(), that's curious. You mean it has no effect on A6/A7 because of their analog, input-only nature?

Because the page http://arduino.cc/en/Tutorial/AnalogInputPins actually uses pinMode() on an analog pin. Ok, that's obviously to set it as OUTPUT. INPUT should be redundant, since they are input by default. But I thought it was a good measure to set them to INPUT, just in case some code previously had set them in OUTPUT mode...


The first six analog pins do have digital circuitry behind them, so pinMode and digitalWrite work just fine. It's just pins A6 and A7 on the surface mount '328 which are analog-only.

Cheers!

cmiyc


Regarding pinMode(), that's curious. You mean it has no effect on A6/A7 because of their analog, input-only nature?

pinMode() has no effect on analog inputs (A0-A7).

When analogRead() is called, the pin switches to an analog input regardless of what the pinMode was set as.


Because the page http://arduino.cc/en/Tutorial/AnalogInputPins actually uses pinMode() on an analog pin.

Yes, because the code in that example is showing how to use the analog pin into a digital pin.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

32teeth

You can actually use A6 and A7 as 'digital' pins with a little bit of logic in your code
below is my craptastic  ]:D example

Code: [Select]
int pinStateA6 = 0;
int pinStateA7 = 0;

void setup()
{
}

void loop()
{
     pinStateA6 = analogRead(A6) > 100 ? 0 : 1;
     pinStateA7 = analogRead(A7) > 100 ? 0 : 1;
}

tentoes

pinMode can be used on A0-A5 to turn the internal pull-up resistor on or off.

    pinMode(A0, INPUT_PULLUP);  //on
    pinMode(A0, INPUT);  //off



DrAzzy

#7
Aug 03, 2015, 07:03 pm Last Edit: Aug 03, 2015, 07:08 pm by DrAzzy
Sigh....

Analog pins A0~A5 are normal pins. You can refer to them as pins 14-19 as well, and they can be used normally as digital pins.

Analog pins A6 and A7 are weird. They can *only* be used for analogRead() - there aren't any registers to write to for them like there are for other pins. I get the impression they were an afterthought (maybe the DIP package was released first, then they're like "hey we have some extra pins on TQFP32, let's connect them to the unused channels on the ADC mux")...

The next iteration of the x8 series (x8PB - only available up to 16k so far though) gives them proper treatment, putting them on a new port with those two pins, plus two pins that used to be a second set of power and ground pins, to make a 4 bit port.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up