I'm still new to microcontroller, I don't know if this is already have a document about it.

I'm using the ATmega8A for my project and I only need 12 out of 23 I/O pins of the microcontroller, which mean that there are 11 pins that are unused. Since floating pin is bad, is it ok to set those unused I/O pins of the ATmega8A to input and connect all of them directly to ground. Also, I'll disable the all the internal pull-up resistor of the microcontroller since I'm using it for extreme low power application and those as I measure can draw up to 500uA.

I would like to know if it possible to connect all of them directly to ground. Will it cause any damage to the microcontroller like for example, there will be high current flow to the ground when start up. I'm using the 32.768kHz real time clock with 3.3V supply voltage for the ATmega8A.

  • 1
    \$\begingroup\$ related: General "rule of thumb" for unused IC pins \$\endgroup\$
    – davidcary
    Aug 2, 2023 at 18:34
  • \$\begingroup\$ Try measuring the current if you configure them simply as outputs (both high and low). \$\endgroup\$
    – filo
    Aug 2, 2023 at 19:42
  • 2
    \$\begingroup\$ What made you reach the conclusion to set unused I/O to input instead of output when you had the chance? \$\endgroup\$
    – Mast
    Aug 2, 2023 at 21:26

4 Answers 4


Your solution will work. There are other options too, as wiring them directly to ground will prevent the use of those pins easily in case you need more pins for temporary testing and debugging.

Another solution is to not connect them at all, and then set them as outputs that can be high or low. If they have a PCB track and test pad they can be used as extra outputs for testing and debugging with an oscilloscope or logic analyzer.

It also allows the pins to be inputs with weak pull-up, so they can also be used as extra inputs for testing and debugging.

Of course if you really need to disable pull-ups for smaller power consumption then if you use these as debug/test inputs they must be fed with proper logic levels, or the pull-ups must be temporarily enabled.

  • \$\begingroup\$ those are some good option, I gonna test to see if those fit for my application, thanks \$\endgroup\$ Aug 2, 2023 at 10:52
  • \$\begingroup\$ You could certainly make then as outputs until they are needed and change them in software to input with or without pull-up as needed for testing/debug. \$\endgroup\$
    – penguin359
    Aug 2, 2023 at 20:17
  • \$\begingroup\$ The test is done yesterday and I think I'm just gonna set it to output high for those unused pins, the debug part, I have a dedicated developement board for this kind of test, this question is for my commercial board that have to work with 5mA current limit for the whole board, that's why I want to disable the pull-up resistor. \$\endgroup\$ Aug 3, 2023 at 5:07

The ATMega8A Datasheet p.61 states:

13.2.4 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.

So, in answer to your question:

Is it ok to set the unused I/O pins of the ATmega8A to input and connect all of them to ground

The datasheet answered:

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.

When you see "excessive currents", think "potentially damaging to your microcontroller".

Note, however, that this is not a recommendation against connecting pins to VCC or ground through a suitably sized resistor.

  • 2
    \$\begingroup\$ And to extend on your last paragraph, the datasheet already suggests that, as it said connecting an external pull resistor is recommended for least power consumption under reset. \$\endgroup\$
    – Justme
    Aug 2, 2023 at 13:35
  • 4
    \$\begingroup\$ Upvoted because you looked into the datasheet! \$\endgroup\$
    – Marcel
    Aug 2, 2023 at 14:16
  • \$\begingroup\$ Many devices are constructed in such a way that general-purpose digital outputs would be incapable of sourcing enough current to cause rapid device damage (since constructing them in such fashion is easier and cheaper than constructing outputs with enough current sourcing capacity to cause damage, and since output sourcing capability would diminish with temperature), so one needn't be excessively paranoid, but a glitch which causes outputs to drive a ground short high may pass enough current to stress the power supply or make VDD sag, which may disrupt operation, which could cause... \$\endgroup\$
    – supercat
    Aug 2, 2023 at 16:45
  • 1
    \$\begingroup\$ ,...damage to the device or power supply circuitry if the condition is allowed to persist. Unless power draw in reset state is important, leaving pins floating until software can explicitly set them to weak pull-up state is for most purposes better and safer than pulling them hard low, which is in turn safer than pulling them hard high. \$\endgroup\$
    – supercat
    Aug 2, 2023 at 16:47

That would be fine: pins initialize to Hi-Z (input) state, and logic low. As long as they are never written to output-high (or weak pull-ups in a low-power application).

But that leaves you vulnerable to programming errors: if the CPU does something unexpected and sets the registers to high, now it roasts itself (or at least draws more current).

Preferred is to set weak pull-ups, to do the same thing without even having to wire them up. Use software to your advantage!

  • \$\begingroup\$ should I connect all the input in parallel and then connect them to ground in series with an 1K resistor? \$\endgroup\$ Aug 2, 2023 at 0:40
  • 4
    \$\begingroup\$ No, use internal weak pull-ups. \$\endgroup\$ Aug 2, 2023 at 0:41
  • \$\begingroup\$ ok, then thanks! \$\endgroup\$ Aug 2, 2023 at 0:42
  • \$\begingroup\$ sorry if it's late to ask but should I need to connect those pin to Vcc or somthing to give some more stability? \$\endgroup\$ Aug 2, 2023 at 0:54
  • 2
    \$\begingroup\$ Stability against what? Pin leakage is ~nA DC, and any AC/RF fields strong enough to be a problem, will certainly disrupt your RTC crystal sooner. Cheers :) \$\endgroup\$ Aug 2, 2023 at 1:43

Update's here,

I've done a few test about some surggestion that's given in the answer.

My conclusion is that, base on my ATmega8A model, the one that draw the least amount of current but still safe in case the microcontroller do something unexpected is to set all of those unsed pins to output HIGH and then leave them float, so that the internal pull-up resistor will not draw current and when it do something unexpected, due to my current protection need like at least 500ms of overcurrent to kick in, there will be no massive current that will fry the ic.

There also a few thing that I forgot to mention. First, the ATmega8A only have an 1mA of budget due to extreme low power application that I'm working. That's also why I run it on 32.768 kHz clock and disable it's internal pull-up resistor. Second, the board space are also limited, the whole board is 50x30mm and there are a lot more component that I have to on that board with the microcontroller, that's why I can't put external resistor on the board 'cause a few minimeter matter.

But thanks for all of your answers and comments, it's a great help!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.