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?
-
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\$Kartman– Kartman2022年01月26日 21:59:04 +00:00Commented 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\$rdtsc– rdtsc2022年01月26日 22:14:30 +00:00Commented Jan 26, 2022 at 22:14
2 Answers 2
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.
-
\$\begingroup\$ Thank you for this explanation, it was very informative. \$\endgroup\$Archon– Archon2022年01月27日 02:41:09 +00:00Commented Jan 27, 2022 at 2:41
-
\$\begingroup\$ By 'a very great current', you mean 'a relatively high current'. \$\endgroup\$TonyM– TonyM2022年01月27日 08:37:56 +00:00Commented 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\$glen_geek– glen_geek2022年01月27日 15:16:34 +00:00Commented Jan 27, 2022 at 15:16
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.
-
\$\begingroup\$ STM32's pull-down resistors are 40kΩ on most pins. \$\endgroup\$JLCPCB Engineer– JLCPCB Engineer2022年01月26日 22:52:13 +00:00Commented Jan 26, 2022 at 22:52