Main Site Documentation

Recommended Default Pin Mappings to Save Power on STM32F4?


I am trying to determine best practice for pin mappings in the device.h file for STM32F4 target. ST has AN4365 , where they provide suggestions for power modes, and when it comes to the pins, they state the following below.

“By default, STM32F4 pins are configured as inputs, except some JTAG pins which can impact the power consumption of the device in different power modes because pins are very sensitive to external noise in input mode I/O.
To avoid extra I/O current, all pins should be configured as analog input (AIN); in this mode the Schmitt trigger input is disabled, providing zero consumption for each I/O pin. We recommend that the I/O speed frequency (driving level) be configured at the lowest possible speed or as an output push-pull configuration, outputting 0 to the ODR. The user should also disable the MCO pin of the clock output if not used.”

Do the pin mapping initializations in the device.h files using Default() or NO_INIT() do any of the suggested defaults? If not, is there an option to do so?


DEFAULT() => TinyCLR OS default state, force to Input pulldown when initialize.

NO_INIT() => TinyCLR OS won’t touch on those pins when initialize.


Thanks @Dat_Tran.
What is the default speed that is setup with Default()?
Is there a way to set the state to Analog Input?

If not, I assume doing that in the .NET layer is the best option?


Is there a way to set the state to Analog Input? => Yes, if you are going to recompile firmware, it is easy to add one more #define to customize whatever you want in your build, or re-define what #DEFAULT() should be in yours.

Speed default when set to Very High Speed which is max speed if device are branch of STM32Fx.


The idea of DEFAULT() and NO_INIT(), set to input pulldown for all pins, NO_INIT just ignore some pins that already configured and need for application run (like your app runs on SDRAM then you shouldn’t change SDRAM pins). You may don’t need to care about NO_INIT if your app doesn’t need bootloader.

Is there a way to set the state to Analog Input?

Yes, if the pins support Analog Input, if those pins don’t support Analog, I am really not sure how.


Thanks, I am rebuilding the image, so will experiment and let you know what kinds of power saving difference we measure.