Skip to main content
Lars Beiderbecke
Senior III
October 18, 2020
Question

What happens when GPIO is sourcing more mA than allowed?

  • October 18, 2020
  • 10 replies
  • 2579 views

My STM32F746 can source 25 mA per pin, but only 120 mA in total.

What happens if we exceed that amount? Will there be a brown out, will the STM32 reset, or will the STM32 get damaged?

This topic has been closed for replies.

10 replies

waclawek.jan
Super User
October 18, 2020

There's no guarantee of what can happen. The world as we know it may come to end. Count on the worst.

(Read, any of what you wrote may happen, and possibly other things, too, e.g. temporary damage, localized damage, decreased reliability with apparently no other problem, etc. The 120mA probably has some margin built in, which may even be huge, and may depend on particular circumstances e.g. excess current duration, slew time, ambient temperature, etc.)

JW

TDK
October 18, 2020

In my experience, the MCU will limit its current output on the GPIO pin to ~25mA and no permanent damage will occur. But as noted above, it's not guaranteed to behave that way.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Lars Beiderbecke
Senior III
October 18, 2020

OK, thanks. Because I intend to use some GPIO pins as "user interface", and I was wondering what would happen if the connected device would draw too much current. Better have some overcurrent protection then, although I don't see how I could enforce the sum limit of 120 mA.

JoniS
Senior
October 18, 2020

Do not expose plain gpio's on some connector and for sure do not expect the user to respect any limits you might tell him/her.(saves you from alot of proplems later on)

Use extra hardware components to ​protect the outputs from reasonably mistakes by end user.(overcurrent, overvoltage etc)

waclawek.jan
Super User
October 18, 2020

@TDK​ 

I believe Lars is more concerned about the cumulative current rather than individual current per pin.

Jan

waclawek.jan
Super User
October 21, 2020

There's probably no bulletproof solution to this problem.

You can simply use a current limited power supply. This wouldn't protect agains excessive current *sink* (which is limited too). Or you can build some sophisticated current measurement system into the supply line (and/or ground), disconnecting supply from mcu when overcurrent occurs.

One way to tackle it would be to add a separate external buffer, and either try to protect that somehow, or just leave it as a "consumable", depending on your application.

JW

gregstm
Senior II
October 22, 2020

I would also be concerned about static electricity damage/disruption if you are giving other people direct access to GPIO pins. What will the user do with the GPIOs? Is it high speed? I would use surface mount ferrite beads (plus small capacitor) and high value resistors to protect each IO, and possibly a zig-zag track layout (through ground fill) to act as a spark gap nearest the user. (Probably best to look at what components/applications ST and Murata offer for ESD). Not recommended - but I have on occasions tested things with a piezo sparker from a gas lighter just to check for software+hardware robustness (can't afford an ESD gun).

Lars Beiderbecke
Senior III
October 22, 2020

My original idea was using a bus transceiver, which lifts the total amount of current to source. The problem is that each pin can be input or output, so the only viable option I found is a SN74AXC4T774, which offers 4 signals in any direction.

If I fix directions, a (de-)multiplexer might work.

The signals involved are of a very low frequency, probably less than 10 kHz.

waclawek.jan
Super User
October 22, 2020

You can consider also serially interfaced IO ports ("expanders"), e.g. MCP23S17

JW