0
\$\begingroup\$

If I have an MCU, e.g. ATTiny85, and I connect a 5V source to a pin on the MCU, what current is flowing?

My understanding is that the pin I'm connecting to will be at 0V and if I connect the 5V source then a large current will flow due to virtually no resistance, but this isn't true.

How is my understanding wrong?

\$\endgroup\$
9
  • \$\begingroup\$ What is connecting a pin to a "5 V input"? This makes no sense. \$\endgroup\$ Commented Aug 14, 2017 at 11:52
  • \$\begingroup\$ @OlinLathrop If I have a wire going from a 5V source directly to a MCU pin \$\endgroup\$
    – CS Student
    Commented Aug 14, 2017 at 11:54
  • \$\begingroup\$ Then the 5 V is not a input. The pin might be configured as input, but the 5 V isn't somehow a "input". That makes no sense. \$\endgroup\$ Commented Aug 14, 2017 at 11:55
  • \$\begingroup\$ @OlinLathrop I've changed the wording in the question, its now a 5V source. \$\endgroup\$
    – CS Student
    Commented Aug 14, 2017 at 12:02
  • 1
    \$\begingroup\$ Also, "0V" at not connected pin doesn't mean "low resistance" (aka "short"). \$\endgroup\$ Commented Aug 14, 2017 at 12:27

2 Answers 2

6
\$\begingroup\$

Assuming you're talking about GPIO pins, it depends on how the pin is configured by the software. A pin configured as an input presents a high impedance, and very little current flows. A pin configured as an ​output and driven low presents a low impedance, and damaging current can flow.

This is why it's generally a good idea to use a series resistor to tie a pin high or low — if the pin is correctly configured, it has negligible effect, but if a software problem causes the pin to be misconfigured, it protects the MCU from damage.

\$\endgroup\$
6
  • \$\begingroup\$ Yes I did mean GPIO pins, sorry I'm not an EE. So if I configure a pin on my MCU to be an input then somewhere inside the MCU attached to the input pin is a large resistor which causes the high impedance? (also, is high impedance the same as high resistance?) \$\endgroup\$
    – CS Student
    Commented Aug 14, 2017 at 12:10
  • 4
    \$\begingroup\$ You might want to add, that the MCU needs to be powered. If it is not powered but connected to ground, connecting 5 V to any pin will cause strange things (powering the chip over the protection diodes and other stuff). \$\endgroup\$
    – Arsenal
    Commented Aug 14, 2017 at 12:16
  • 1
    \$\begingroup\$ No, there's no "large resistor". A GPIO pin has two buffer circuits attached to it -- an input buffer that implicitly has a high impedance, and a "tri-state" output buffer that can be driven high, low, or off. In the "off" state, it also has a high impedance. \$\endgroup\$
    – Dave Tweed
    Commented Aug 14, 2017 at 12:17
  • \$\begingroup\$ @DaveTweed if there is no resistor involved then how is high impedance achieved? (from my understand high impedance is the same as high resistance) \$\endgroup\$
    – CS Student
    Commented Aug 14, 2017 at 12:21
  • 1
    \$\begingroup\$ The transistors used to construct the buffers inherently have a high input impedance. They also have a high output impedance when switched off. No resistors needed. \$\endgroup\$
    – Dave Tweed
    Commented Aug 14, 2017 at 12:23
2
\$\begingroup\$

If I have an MCU, e.g. ATTiny85, and I connect a 5V input to a pin on the MCU, what current is flowing?

If that MCU pin is configured as an input, then there is almost zero current, for a static input voltage which is within the allowed voltage range for that IC (often, but not always, limited by the supply rails). Check the datasheet for your specific MCU - look for the "input leakage current" parameter, typically a few nA.

From page 161 (in the current version) in the ATtiny85 datasheet, I have edited one table to show only these relevant values:

extract from ATtiny85 datasheet showing input leakage current values

Here you can see that typical input leakage current is < 0.05 uA (< 50 nA) for that device.

My understanding is that the pin I'm connecting to will be at 0V

No. An input is not a low resistance path to "0V", which would be required for a "large current" to flow (as you describe below).

and if I connect the 5V input then a large current will flow due to virtually no resistance, but this isn't true.

Yes, that isn't true because of the incorrect initial assumption that the input pin is at 0V.

How is my understanding wrong?

Ignoring some practical aspects (e.g. ESD structures and analog inputs, and assuming any internal pull-up or pull-down resistors are not enabled) a digital CMOS IC logic input is often internally a pair of complementary MOSFET gates - very high resistance. Therefore do your research about the characteristics of a MOSFET and how it switches.

\$\endgroup\$
4
  • \$\begingroup\$ Why wouldn't the input pin be at 0V? \$\endgroup\$
    – CS Student
    Commented Aug 14, 2017 at 12:30
  • 1
    \$\begingroup\$ @CSStudent - Perhaps I see your confusion (although you seem to have already understood it now, during the comments on the helpful answer from Dave Tweed). Saying that a circuit node is "at 0V" can imply it has a low resistance path to 0V (then a large current would flow when voltage is applied, due to that low resistance) - that seems to be what you expected. However a CMOS digital input has a high resistance path to 0V (in this case, so high that it is effectively considered "floating"). Saying "at 0V" is ambiguous, and that seems to be where the confusion occurred. \$\endgroup\$
    – SamGibson
    Commented Aug 14, 2017 at 12:57
  • 1
    \$\begingroup\$ @CSStudent - To put it another way: a "floating CMOS input" (where you might measure 0V, but might instead measure other voltage values, depending on the exact circumstances) is not the same as "a circuit node with a low resistance path to 0V" (where you will measure 0V). This is effectively what Ali Chen says in this comment. That is why EEs would describe an unconnected CMOS input as "floating" and not as "at 0V", to "disambiguate" what is meant. \$\endgroup\$
    – SamGibson
    Commented Aug 14, 2017 at 13:15
  • 1
    \$\begingroup\$ Thanks for the follow up comments. They've greatly helped my understanding \$\endgroup\$
    – CS Student
    Commented Aug 14, 2017 at 14:59

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.