Groundig unused atmega328 pins?

Hi everybody, I'm currently using a few atmega328 standalone on breadboards and I'm wondering if it may help to ground unused I/O pins like it's been done with any logic gate to prevent floating input values. Not that I have a specific problem as of now. But since I'm going to port those breadboard prototypes to a PCB, I'd like to know if I should ground those pins in advance.

Anyone has a few words to say about that?

Cheers :-)

robitabu: Hi everybody, I'm currently using a few atmega328 standalone on breadboards and I'm wondering if it may help to ground unused I/O pins like it's been done with any logic gate to prevent floating input values. Not that I have a specific problem as of now. But since I'm going to port those breadboard prototypes to a PCB, I'd like to know if I should ground those pins in advance.

Anyone has a few words to say about that?

Cheers :-)

I wouldn't bother with grounding pins. First if there was ever a sketch loaded in error that changed the pin to an output pin and set output to high you could damage the pin. Second, if your concerned about floating inputs, just enable the internal pull-up resistors for those pin you will not be using.

Lefty

or add 1K pull downs, Lefty's method is best, my method is a quick and dirty patch for when you are in a hurry.

Bob

retrolefty: ... if your concerned about floating inputs, just enable the internal pull-up resistors for those pin you will not be using ...

Thank you Lefty, clever suggestion :-)

Anyone has a few words to say about that?

Floating pins usually don't do much.

In a noisy environment, you may want to ground them or pull them to Vcc. You can pick the resistor value to minimum current draw. I typically put them to digital output high and pull them to Vcc, via a 10k - 47k resistor network.

Floating pins though can cause power drain in sleep mode. Fortunately the 328 has some hysteresis in the input stages which may help.

Basically any "standard" CMOS input stage is an inverter and will consume non-trivial power if the input is somewhere in the middle of the range (the "forbidden region"). Here non-trivial means its an issue for battery-powered circuitry in sleep mode - something on the scale of 1mA might flow from that one input circuit when the whole chip is supposed to be shutdown (a few uA usually).

Also a floating input could be sent into oscillation due to capacitive feedback - in theory at least - symptom is increased power drain in that input circuit and gates further down the line.

In sleep mode the 328 and other AVR microcontrollers disconnect the input circuitry from the pins and grounds the input inverter, so none of this is an issue in sleep mode.

In general it is wise to avoid floating inputs in any deployed circuit - for breadboarding you'd only worry if it stopped things working.

For the 328 the advice to use internal pull ups is good I think, but few bother for prototypiing.

"In sleep mode the 328 and other AVR microcontrollers disconnect the input circuitry from the pins and grounds the input inverter, so none of this is an issue in sleep mode."

That may be true for inputs - outputs are still driven.

I have a remote control that uses keypad.h library. I was using diodes with anodes to interrupt and cathodes to keypad row pins to create an interrupt to wake up from power down sleep mode. Couldn't make it work - turns out the keypad library was leaving the column pins high. As part of going to sleep, I had to write the column pins low so a cathode would get pulled low when a key was pressed connecting a row to a column, and then write them back high on waking up.

Atmel recommends taking unused pins High or Low so they don't oscillate. I define all unused pins as inputs with internal pullups enabled.

a 74HCT240 Will oscillate 1 section or many If the inputs are open usually at about 30-60 MHZ. They get real hot and without a scope are really difficult to separate from a shorted output, Add a crystal and a telegraph key and you have a 1/2 watt transmitter. One section for the oscillator one as a buffer and 4 in parallel for the "Power Amp" there was a write up in the ARRL handbook (Great way to learn basic electronics from the ground up) in the early 2000's. As MarkT pointed out an open input is not really a good thing to have. I've always grounded the inputs as ground is usually the easiest thing to find when laying out a PCB. If one makes sure that unused pins are set to output and low there is no issue possible that could really cause damage except as pointed out for Low Current applications.

Bob

I thank you all for your inputs, quite precious ones! You gave me ideas to think about in the next few days. I appreciate that :-)

retrolefty:
…just enable the internal pull-up resistors for those pin you will not be using…

I’ve read Atmel’s datasheet in the meanwhile (why don’t I do that before starting a new thread?!!). It clearly suggests enabling those internal pull-ups instead of wiring the free pins to Vcc/GND. I’m glad to see Lefty’s suggestions keep proving themselves rock solid :slight_smile: I will definetely enable the pull-up resistors and not ground anything at all!

robitabu:

retrolefty: ...just enable the internal pull-up resistors for those pin you will not be using...

I've read Atmel's datasheet in the meanwhile (why don't I do that before starting a new thread?!!). It clearly suggests enabling those internal pull-ups instead of wiring the free pins to Vcc/GND. I'm glad to see Lefty's suggestions keep proving themselves rock solid :-) I will definetely enable the pull-up resistors and not ground anything at all!

Be careful and judicious with your praise. I think you find anyone around here with a high post count has contributed their fair amount of brain farts to go along with their useful tips. :D

Lefty