I'm using this MCU from STM2 on a board and the PCB layout is as follows:
I will not use several MCU pins, so they are disconnected as shown above(pin 6, 7, 8, 11, 12 ect.). Also I cannot do any physical change anymore because already ordered the board.
But later, I was wondering about how to treat these unused MCU pins. I came over this question.
In my case, I use STM32CubeIDE to set GPIOs and unused pins are shown in grey colour and when I hover on them it says "Reset_State" as shown below:
I don't know what "Reset_State" does to the pin. What would be the best option to avoid an issue such as EMI in my case? Should I set them as GPIO input or leave as Reset-State in software before flashing?
(As I mentioned I cannot make any physical change to the board.)
2 Answers 2
The answer is in the data sheet page 62.
It says to avoid current consumption of floating IO pins, they must be configured as analog pins, or forced to some value by using internal pull-ups or pull-downs (does not matter which one) or configuring the pin as output (high or low, does not matter).
In the reset state (i.e. default, left unconfigured), the pins are on this MCU configured as digital IO pins.
You need to define them as analog mode, digital inputs with pull resistor, or define them as outputs.
-
\$\begingroup\$ Very helpful and thorough answer. Thanks! \$\endgroup\$pnatk– pnatk2024年07月13日 23:30:31 +00:00Commented Jul 13, 2024 at 23:30
-
\$\begingroup\$ "They default to being analog pins."--not according to this,Page 35, Table 12, Notes, indicates that. "Unless otherwise specified by a note, all I/Os are set as floating inputs during and after reset" So not analog inputs out of reset. \$\endgroup\$user319836– user3198362024年07月14日 12:16:34 +00:00Commented Jul 14, 2024 at 12:16
-
\$\begingroup\$ @RussellH So better to set the unused pins as GPIO inputs with pull-down resistors? \$\endgroup\$pnatk– pnatk2024年07月16日 13:48:28 +00:00Commented Jul 16, 2024 at 13:48
-
\$\begingroup\$ I would monitor the supply current and test for lowest current consumption. I just know that floating inputs are undesirable. \$\endgroup\$user319836– user3198362024年07月16日 17:59:39 +00:00Commented Jul 16, 2024 at 17:59
-
\$\begingroup\$ @pnatk Datasheet is still correct. The pins just need to be configured from the default/reset state to either analog mode, or input with any pull direction, or output that pushes into any state. \$\endgroup\$Justme– Justme2024年07月16日 18:02:51 +00:00Commented Jul 16, 2024 at 18:02
In the case of GPIOs if you want to be sure you know the state of each, you can assign them an internal pull up/down resistor. External components are not needed, the MCU has an internal function to pull the signal to each rail.
Hard wiring them to ground I wouldn't advice during development phase, as a problem in code might break the MCU. That would happen in the cases where you assign the pin to another state than what you hard wired it.
The Stm32CubeMX tool displays "Reset_State", meaning that the user has not specified anything for the pin, so it is in the default reset state in the initialization routine. Clicking it removes the configuration that was selected:
Before clicking the pin was configured for UART:
After clicking Reset_State the selection is removed:
-
\$\begingroup\$ I cannot make any physical change to the board. I mentioned this in question 2 times. \$\endgroup\$pnatk– pnatk2024年07月13日 19:12:12 +00:00Commented Jul 13, 2024 at 19:12
-
\$\begingroup\$ I'll try to re-phrase to make it clear. I meant pulls internal to the MCU. \$\endgroup\$Ralph– Ralph2024年07月13日 19:14:05 +00:00Commented Jul 13, 2024 at 19:14
-
\$\begingroup\$ I was thinking to set unused pins as GPIOs and as inputs with pull down resistors. Why pullup? \$\endgroup\$pnatk– pnatk2024年07月13日 19:14:46 +00:00Commented Jul 13, 2024 at 19:14
-
\$\begingroup\$ In some stm32 families the pull down consumes less power. I would guess the f3 is the same, so there's no reason to use a pull-up, it's just an option. \$\endgroup\$Ralph– Ralph2024年07月13日 19:19:05 +00:00Commented Jul 13, 2024 at 19:19
-
1\$\begingroup\$ @RussellH I double checked and I have been wrong for all these years. At least this specific MCU at reset state sets pins into digital input mode, not analog mode, which is a bit stupid because you can't even read the pins until you enable peripheral clocks to the GPIO ports. I will edit my answer with the info. \$\endgroup\$Justme– Justme2024年07月14日 14:35:53 +00:00Commented Jul 14, 2024 at 14:35