Why is analog mode recommended for unused GPIO pins?
When a pin is configured in any digital mode (input, output, or alternate function), the input Schmitt-trigger buffer is active. The Schmitt trigger consumes power even when the pin is stable, and consumes significantly more power when the input voltage floats near the switching threshold. In analog mode, the digital input buffer is completely disconnected from the pin — there is no Schmitt trigger, no shoot-through current, and no digital readback path. The pin is electrically isolated from the digital domain.
This makes analog mode the absolute lowest-power configuration for any GPIO pin. On STM32, the power difference is measurable: a single floating digital input can draw 1-5 uA of shoot-through current, while an analog-mode pin draws essentially zero. In a system with 50+ unused pins, the aggregate savings can be the difference between meeting a 10 uA sleep-current specification and failing it by an order of magnitude. This is why STM32CubeMX defaults unused pins to analog mode in its code generator, and why the reference manual dedicates a note to it in every GPIO chapter.
A secondary benefit is safety: analog-mode pins cannot generate spurious digital interrupts, cannot be accidentally read by software as valid digital data, and cannot inject noise into peripheral muxes. It is the "do nothing and cause no harm" configuration.
Source: GPIO Q&A
