When I was creating a new project using the STM32CubeMX, I saw a check box stating that setting all free pins as anlog will decrease the power consumption. I couldn't figure out how it works. How can configuring the free pins as analog decrease the power consumption of an MCU?

HAL Settings


According to the reference manual:

enter image description here

This apparently can reduce the typical current draw from uA to nA. It's not clear if they make assumptions about whether the pins are tied high, low or floating for these comparisons.

  • Floating inputs into a Schmidtt can draw lots of microAmps, possibly even milliAmps. Hence the Schmidtt is disabled.

For minimum propagation delay near the 2 thresholds, a Schmidtt needs a very fast amplifier built into the circuistry. Pleasantly, a simple two_FET inverter (Nchannel + Pchannel) provide the speed, but will consume LOTS OF CURRENT near the thresholds. Thus SLOW inputs (slow ramps) or floating inputs, will waste lots of current. Unless you chose to disable the input.

Estimate of the current: Idrain = K/2 * W/L * Ve^2

Let K = [0.5 * (100uA/volt^2)], W/L = 10, Ve = 1

Idrain = [ 0.5 * 100 uA/volt^2] * 10 * 1^2 = 500 microAmperes

  • And the low_current pullup/pulldown can draw various microAmps. Hence these are disabled.

If a pin would be externally held to the positive or negative rail, it will use the same trivial amount of power when configured for analog mode as for digital mode. Likewise, there would generally be negligible extra power consumption from enabling internal pull-up of a pin which would either be externally pulled high or disconnected would draw no current, or an internal pull-down of a pin that is externally pulled low.

Enabling an internal pull-up on a pin which is externally pulled low, however, will substantially increase current draw from the chip, and enabling an internal pull-down on a pin that is externally pulled up will likely increase current draw in whatever external device is pulling the pin up.

In the case of a pin which does not have internal pull-ups or pull-downs, enabling a digital input will have negligible effect on power consumption when the input is near a rail, but may increase power consumption when the input is near the switching point. In many cases, digital inputs will be fed into an inverter whose output is pulled high when the input is low, and pulled low when the input is high. Oftentimes, there will be a voltage between the high and low levels which is high enough to partially turn on the pull-down transistor but also low enough to partially turn on the pull-up transistor. Having both transistors be partially on can sometimes substantially increase current consumption, though input circuit design can trade off worst-case current draw for response time (if an input doesn't need to switch quickly, it can use small transistors that won't pass much current even when turned on), and most microcontrollers strike a balance which will result in a current increase which is measurable, but not so large as to pose a meaningful risk of overheating.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.