1
\$\begingroup\$

While GPIOs on controllers (STM32F and L series with respect to this question) are voltage driven, do they require a small amount of current?

If so, what is the minimum amount of current that is required to ensure that a pin toggles/reads reliably?

The practical reason behind this question is that if I connect a resistor to a GPIO to ensure that the microcontroller does not source or sink too much current, one can add a resistor.

Now in turn, how large can one make that resistor, and how small can the current be made to be, before the PIN will not sense a state change?

TonyM
25.1k4 gold badges41 silver badges67 bronze badges
asked Jan 26, 2022 at 21:36
\$\endgroup\$
2
  • 2
    \$\begingroup\$ The datasheet will specify this. For a cmos device this a generally a very small current - as in less than a microamp. However, if you enable pullups/pulldowns then this will change. Off the top of my head the pu/pd effective resistance is around 50k. Again, the datasheet is the reference. \$\endgroup\$ Commented Jan 26, 2022 at 21:59
  • 2
    \$\begingroup\$ Do note, that using very high value resistances will make long traces more susceptible to EMI. Use with caution around antennas, DC-DC switchers, anything electrically noisy. \$\endgroup\$ Commented Jan 26, 2022 at 22:14

2 Answers 2

1
\$\begingroup\$

For the static case, spec sheet says leakage current of general-purpose I/O pin is +/- 1uA. Be aware that leakage current is highly temperature dependent, being highest at high temperature. This 1uA spec is not exceeded at the highest operating temperature.

At room temperture, you're likely to find that leakage current is far below the 1uA spec.
Since a valid high is between 55%-65% of Vdd, and a valid low is about 30% of Vdd, you could approach a 1MEG ohm pullup/pulldown resistor. BUT, this simple static analysis is not the whole story: as @rdtsc has pointed out, any adjacent traces or adjacent pins that toggle up and down can cause noise spikes to influence this weakly-pulled I/O pin...so 1MEG ohm is very risky.

Internally, pull-up and pull-down are roughly 50k ohm equivalent. For an unterminated input pin, using these internal terminators should ensure a noise-free logic level, unless the I/O line is extremely long and/or is adjacent to sources having unusually-high \$dV/dt\$. For this case, capacitive coupling should be considered (I/O pins have 5pf internal capacitance, typical).

Any unused I/O pins should certainly be terminated - use the internal pull-up or pull-down resistors for this purpose - there is only a very tiny current penalty for doing this...only leakage currents flow. A floating I/O pin can easily cause significant current to flow; far higher than leakage current. This is called shoot-through current, all wasted as heat.

answered Jan 26, 2022 at 23:28
\$\endgroup\$
3
  • \$\begingroup\$ Thank you for this explanation, it was very informative. \$\endgroup\$ Commented Jan 27, 2022 at 2:41
  • \$\begingroup\$ By 'a very great current', you mean 'a relatively high current'. \$\endgroup\$ Commented Jan 27, 2022 at 8:37
  • \$\begingroup\$ @TonyM Yes - I've never seen shoot-through current specified, so we can only guess how destructive it might be. It is never useful, especially for circuits powered by feeble supplies. Have edited - but not with hard data. \$\endgroup\$ Commented Jan 27, 2022 at 15:16
1
\$\begingroup\$

They're CMOS inputs so the amount of current needed is small, all you need to do is charge the gate and miller capacitance of the input pair. Check the datasheet, or perhaps use a capacitance meter to measure it.

If you have pull-up or pull-down enabled on the input then a larger current will be needed to counteract the pull.

Also: the larger the resistance the slower the input will be.

answered Jan 26, 2022 at 22:01
\$\endgroup\$
1
  • \$\begingroup\$ STM32's pull-down resistors are 40kΩ on most pins. \$\endgroup\$ Commented Jan 26, 2022 at 22:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.