What to do with unused pins?

I'm getting ready to draw the PCB for a project.
Some of the analog pins of the chip are not used.
Do I need to do something with them? Ground them? Or just leave them be?

Leave them be. If the pin is connected to GND and you accidentally configure it as an output and set it HIGH, you've fried the processor. If the pin is connected to GND and you accidentally enable the internal pull-up, you're wasting electricity. If the pin is connected to VCC and you accidentally configure it as an output and set it LOW, you've fried the processor.

Ideally, you will configure the unconnected pins as inputs with the internal pull-up resistor enabled.

I would bring them out to a small pad, if there is space in the board, because they might be handy in the future.

if you do that make sure you can reprogram your micro controller, because if you can what would be the use of having them open anyways?

Hi,
Assuming you leave them be (no connections to Vcc/Gnd), is there any difference at all between making the pins outputs, and making them inputs with pull-ups enabled? Thanks!

FYI, similar thread here:
http://forums.adafruit.com/viewtopic.php?f=25&t=20742

Assuming you leave them be (no connections to Vcc/Gnd), is there any difference at all between making the pins outputs, and making them inputs with pull-ups enabled?

Yes. If you accidentally touch a hot wire to an output set low you've short-circuited your processor and fried it. If you accidentally touch a ground wire to an output set high you've short-circuited your processor and fried it. If you accidentally touch either wire to an input w/ pull-up you won't even notice.

Or are you asking about power consumption? In which case there's no difference.

If you are building a PCB for testing purposes, mapping the unused pins to a pad so you can use them on a breadboard later on is the way to go.

If the PCB is going to be a stand-alone device, then it would be advisable for you to connect them to one of the logic levels. +5V or GND. The reason for this is, as hinted by Coding Badly, the possibility that if the pins don't have a fixed voltage on them, they'll fluctuate and cause the logic on the pin to change and consume power. It's up to you really...

However, you must take care when using the pins when you do this. Or put an external pull up on that pin. That way, you'll be safe in any of these:

Ideally, you will configure the unconnected pins as inputs with the internal pull-up resistor enabled.

Ideally you would just leave them as Atmel does, in their default condition.

Don

Ideally you would just leave them as Atmel does, in their default condition.

Or even more ideal, follow Atmel's guideline for unconnected pins...

13.2.6 Unconnected Pins
If some pins are unused, it is recommended to ensure that these pins have a defined level. Even though most of the digital inputs are disabled in the deep sleep modes as described above, floating inputs should be avoided to reduce current consumption in all other modes where the digital inputs are enabled (Reset, Active mode and Idle mode).

The simplest method to ensure a defined level of an unused pin, is to enable the internal pull-up. In this case, the pull-up will be disabled during reset. If low power consumption during reset is important, it is recommended to use an external pull-up or pull-down. Connecting unused pins directly to VCC or GND is not recommended, since this may cause excessive currents if the pin is accidentally configured as an output.

Nice... glad to see we weren't way off on the answers. :slight_smile:

Or even more ideal, follow Atmel's guideline for unconnected pins...

So we agree that when he designs his board he just leaves the pins unconnected, or better yet brings them out to an accessible pad. The enabling of the internal pull-ups could be done, if desired, by any program when the board is actually used. This enabling would have to be part of each individual program since the enabling is undone at every reset.

Don

floresta:
So we agree that when he designs his board he just leaves the pins unconnected

Yes. Unused pins should be unconnected.

or better yet brings them out to an accessible pad

A very good idea.

The enabling of the internal pull-ups could be done, if desired, by any program when the board is actually used.

Yes.

This enabling would have to be part of each individual program since the enabling is undone at every reset.

In my case, I would (clone [if necessary] and) modify the core so enabling the pull-ups on unused unconnected pins (especially ones without pads) is performed before the Sketch starts. That is, after all, the point of a computer: to do the simple repetitive tasks that we humans tend to forget.

I did a load of testing around this sort of thing (written up here: http://electronicsfordogs.com/node/15), and found that the absolutely lowest power way to leave unused pins is to set them as LOW outputs. However, given the risks with this, it's probably a far better idea to accept a tiny amount of extra current and set unused pins as inputs with the pull up resistors enabled.

But thanks for the idea about breaking unused pins out as pads - definitely going to do that from now on!

You may want to disconnect pins 0 and 1 (TX and RX) when running the pin_mode_power_consumption test. I suspect driving RX low while connected to the serial / USB converter may cause problems.