Electrical – STM32F103 GPIO and wrong configurations

gpiopulluppush-pullstm32stm32f10x

I have a few questions about gpio.

First

What if two push-pull pins with high level connected? My point of view is that there is no way for current and nothing bad will happen. And reading of pin level will give us 0.

Second

What if two input pins with pull-up connected? I think it will increase current level in line but nothing bad will happen. Reading of input will give us 1.

Third

Why should I use push-pull as output if I want to drive a line? What's wrong with switching pull-up and pull-down resistors?

And fourth

Could you give an example of pins configuration which can cause both or one of them to burn out?

Thanks.

Best Answer

First

What if two push-pull pins with high level connected? My point of view is that there is no way for current and nothing bad will happen.

[Updated following suggestions from Wouter van Ooijen - thanks Wouter!]

Parallel connecting push-pull outputs from the same IC can work. The current flow between the outputs (since no two outputs are identical, even on the same IC) should be small. This is sometimes done to increase the current capability of the output.

However examples of potential problems include (a) not switching all connected outputs simultaneously (which can then cause the problem described in your "fourth" question). I've seen this when engineers try to use this technique, and they forget to switch all pins - suddenly they have a very hot IC. Even brief differences in timing between the switching of the outputs can trigger other issues e.g. due to brief high current flow and marginal decoupling; and (b) connecting push-pull outputs which, although both at a logic "high", are actually at different voltage levels e.g. ICs connected to different power rails.

And reading of pin level will give us 0.

No. A pin set to "high" as you said, will read "high" (i.e. logic 1) when connected to an input.

Second

What if two input pins with pull-up connected? [I assume you mean pull-up resistor] I think it will increase current level in line

Consider the very high input resistance of typical inputs. That means that just connecting a pull-up resistor to an input, will only cause a tiny current to flow.

nothing bad will happen. Reading of input will give us 1.

True. Inputs should always be pulled up or down to a suitable voltage (e.g. a power rail), usually through a resistor although exact details depend on several factors. Unconnected inputs are another bad design practice.

Third

Why should I use push-pull as output if I want to drive a line? What's wrong with switching pull-up and pull-down resistors?

It's not clear what you mean by "switching pull-up and pull-down resistors". A typical alternative to using push-pull output drivers, is an open-drain (open-collector) arrangement, with pull-up resistor(s) as used for the I2C bus, for example.

Some advantages of push-pull include higher speed and output drive current; disadvantages include current consumption and inability to safely have multiple outputs active simultaneously on the same signal line (see answer to your next question below). At a more advanced level, things like slew-rates, termination and EMI are also factors to take into account.

And fourth

Could you give an example of pins configuration which can cause both or one of them to burn out?

The classic example of that dangerous situation is two push-pull outputs (in the same or different devices), connected together, with one driven to a logic high, and the other driven to a logic low. That will effectively place a short-circuit across the power supply (limited by the resistances internal and external to the devices). Whether it actually causes either to "burn out" will depend on what protections the devices have for excessive output current, and the resistances involved.


Based on your questions. I suggest it would be worthwhile reading more about the internal circuitry in common push-pull and open-drain (open-collector) IC outputs, and how they work. I expect that will help to clarify your knowledge in this area.


Edited to add - some other relevant EE.SE Q&A and Wikipedia pages which might be useful reading include:

STM32 Understanding GPIO Settings

Push-pull/open drain; pull-up/pull-down

https://en.wikipedia.org/wiki/Push%E2%80%93pull_output

https://en.wikipedia.org/wiki/Open_collector

Related Topic