5

I have some unused pins, should I connect them together and to the ground or leave them floating?

  • 2
    Just leave them floating. The only problem with that is that under certain circumstances this can cause the MCU to use a bit more current. This is only a problem if you run of batteries. The datasheet suggest enabling the internal pull-ups, like Majenko suggested, but I never had much luck with that, as it ended up drawing more current somehow. In the end I set them to OUTPUT and LOW. – Gerben Feb 24 at 19:15
  • 1
    @Gerben With the pullups enabled you can only get leakage current through the MOSFETs and internal resistor (which will be in the order of nano amps, if that). With an input floating current gets drawn every time the input switches state as it flaps around. Actively driving a disconnected output will theoretically cause more current consumption through the input circuitry since it is only the leakage current of the FETs that limits it, not the leakage current plus the resistance of the pullup. – Majenko Feb 25 at 15:12
  • 1
    @Gerben Leakage current is stated as 1µA @ 5.5V through the input circuitry in the datasheet. That means a resistance of 5.5MΩ. Add to that the ~30kΩ of the pullup and the leakage would be 0.995µA with the pullup enabled, compared to 1µA with the output being driven. – Majenko Feb 25 at 15:20
  • 1
    @Gerben You might find this interesting: ti.com/lit/an/scea046/scea046.pdf – Majenko Feb 25 at 15:27
  • 1
    @Gerben In sleep mode the input is disconnected and the input to the schmitt trigger is clamped to ground. – Majenko Feb 25 at 15:36
17

The simplest thing to do is set them to INPUT_PULLUP. If you want a purely hardware solution then you could connect them to GND through some resistors (10kΩ or whatever you have in that kind of order of magnitude will do).

You don't want to just tie them directly to ground, and you don't want to link them directly together - that could lead to short circuits and dead IO ports if any of the pins happened to get set as output and HIGH in software.

|improve this answer|||||
  • How would using the internal pull-up resistors lead to higher current consumption (Gerben's comment)? Perhaps address that in your answer (whether it is true or not)? – Peter Mortensen Feb 25 at 15:07
  • 1
    It wouldn't. It would do the opposite. A pulled up pin can only use current that flows as "leakage current" through the input circuitry (minuscule amounts). A floating pin uses current every time it causes the input circuitry to switch states. – Majenko Feb 25 at 15:09
  • It was just my observation in one or two of my projects. So take that with a grain of salt. – Gerben Feb 25 at 15:45
2

I saw instability with a kiosk audio player I built years ago, when I left the unused pins floating. Once I grounded them through a 10k resistor, all was OK. This was in a very dry environment so I suspect static was the problem.

|improve this answer|||||
0

Leaving them floating in most cases won't do any harm. Even touching the pins won't destroy anything. Tying extra external hardware is just unnecessary (though a 10k resistor would be harmless as well). Of course, you could also think about potential extra usages for those pins if you want to make your design a bit "future-proof". For example, adding 4k7 pull-up resistors to A4 and A5 and a connector could allow you to use the I2C interface for additional functions.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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