Skip to main content
Jianxuan He
Associate II
February 5, 2018
Solved

STM32L031 alternate function

  • February 5, 2018
  • 2 replies
  • 828 views
Posted on February 05, 2018 at 05:15

I am using STM32L031 by power of battery, so I wish to save power consumption.

Now the current consumption is about 200uA at stop mode.

May I change SWDIO and SWCLK to analogue GPIO after initialization?

May I further save power consumption by this way?

If OK, could you give some sample code to change 

SWDIO and SWCLK to analogue GPIO?

Thanks.

    This topic has been closed for replies.
    Best answer by Szymon PANECKI
    Posted on February 05, 2018 at 08:48

    Hello Jianxuan He,

    Analog input is a recomended mode for all GPIOs, which are not used in the application. This solution reduces the current consumption of MCU.

    I confirm, that you can change confuguration of the SWDIO and SWCLK pins to analog inputs. During the reset state of MCU these pins will be automatically reconfigured back to their original functions in order to act as a debug interface.

    In addition I would recomend to switch off all clocks for GPIOs before entering STOP mode. This can also reduce the current consumption a little bit.

    Regards

    Szymon

    2 replies

    Szymon PANECKI
    Szymon PANECKIBest answer
    Senior III
    February 5, 2018
    Posted on February 05, 2018 at 08:48

    Hello Jianxuan He,

    Analog input is a recomended mode for all GPIOs, which are not used in the application. This solution reduces the current consumption of MCU.

    I confirm, that you can change confuguration of the SWDIO and SWCLK pins to analog inputs. During the reset state of MCU these pins will be automatically reconfigured back to their original functions in order to act as a debug interface.

    In addition I would recomend to switch off all clocks for GPIOs before entering STOP mode. This can also reduce the current consumption a little bit.

    Regards

    Szymon

    Jianxuan He
    Associate II
    February 5, 2018
    Posted on February 05, 2018 at 08:56

    Dear 

    Szymon,

    Thanks for your timely support!

    I would try to further save power consumption.

    Thanks!