cancel
Showing results for 
Search instead for 
Did you mean: 

What to do with unused IO's

DJ1
Associate III

Here in the below image from the Cube MX it suggests that, SET all the free pins as analog (to optimize the power consumption). How does it help. Also is it applicable to all the controller families?

 

DJ1_0-1698466663322.png

 

6 REPLIES 6
Danish1
Lead III

Digital inputs have circuits that look like NOT gates, where a P-channel MOSFET has its source connected to Vdd and an n-channel MOSFET has its source connected to Vss. The gates are connected to the input pin and the drains connected together as the output of the NOT gate.

When the pin is at Vss i.e. 0V, the p-channel mosfet is turned on but the n-channel one is turned off. So the output of the NOT gate is high, and no current flows between Vdd and Vss.

When the input pin is at Vdd the n-channel mosfet is on but the p-channel mosfet is off, so the output is low and no current flows between Vdd and Vss.

When the input pin is somewhere between Vdd and Vss, both p-channel and n-channel mosfets will be partially turned on so current will flow between Vdd and Vss - wasting power.

Ways to fix this are to disable this NOT gate (analog mode) or ensure that the pin isn’t just “floating” but is either Vdd or Vss (enabling pull-up or enabling pul-down or having the pin as a digital output, or having external circuitry that holds the pin high or low).

Analog is not the only way to do this.

AScha.3
Super User

...and yes, this is same for all (cmos) chips , if a pin after startup is just an open floating input.

If you feel a post has answered your question, please click "Accept as Solution".
Peter BENSCH
ST Employee

In analogue mode, the GPIO is connected to the respective analogue function instead of the internal digital Schmitt trigger, because the GPIO in question is otherwise very sensitive to interference signals due to the high-impedance input.

With older STM32s such as F1, F2, F3, the GPIOs were still set to digital input by default and had to be explicitly set to analogue input. With newer families (if I remember correctly with L4) this was then changed to default = analogue input.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
AMacd.1
Associate III

I know this is a very old topic but, in my mind, the question hasn't been answered.  What isn't clear to me is:

1. Why is setting unused IO to analogue preferred over the following choices?

  a. Setting all unused IO to PP output high or low

  b. Setting all unused IO to input pullup or pulldown

2. Does CubeMX only offer the analogue option instead of the other ways listed above?

If this topic is too old, I will gladly open a new question.

Hi @AMacd.1

Thanks for your thoughts, which certainly fit the topic. But in my opinion, both questions of the TO have been answered. To your ones:

  • Output PP: there may be a risk of this output short-circuited against the other potential without realising it, which can overload the output and lead at least to high currents and also to destruction of the device
  • Input pullup or pulldown: this is a possible setting, but it must be taken into account that in the event of an (undetected) short circuit to the other potential, a for ULP applications non-negligible current flows
  • These additional options you mentioned can at least partially be used, but must be set explicitly in CubeMX

Does it answer your questions?

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
AMacd.1
Associate III

Not completely, @Peter BENSCH .  My question was not about application conditions but what was going on under the hood when analog input was selected.

However, I just discovered section 8.3.13 (page 271), RM0394, and I read the following, "the Schimtt trigger input is deactivated, providing zero consumption for every analog value of the I/O pin."  I guess that is the answer for ports that have an analog alternate function. (I know, RTFM, right?)

However, not all pins have an analog alternate function.  Does this analog setting (disabling of the schmitt trigger gate) occur on all IO regardless of whether the IO has an analog alternate function?  I was surprised to see that, according to section 8.5.1 on the same ref manual, the MODER bits on all of the IO ports (A to E & H) have an analog mode setting.  Does this actually do anything on ports that don't actually have an analog alternate function?  I'm guessing "yes" and that would also be a surprise.

I am new to the STM32 products, coming from a long experience with a different MCU which does not have an analog input option for every IO pin.