Skip to main content
Explorer
December 6, 2023
Question

STM32L072 Standby Mode problems

  • December 6, 2023
  • 3 replies
  • 1497 views

Hello!

I'm using the DISCO-L072CZ-LRWAN1 board and have some trouble using the low power modes.

It seems whenever i enter the low power mode, it immediately wakes up again, I've tried following a few of the guides and can't see what I'm doing wrong. The board steadily draws 45-55 mA from my power supply, and i would expect it to be a lot lower.

I generated a project for the board from MxCube and using CubeIDE, the project is empty except for the init functions and the code below.

Am i missing something here??

This is my code:

    RCC->APB1ENR |= RCC_APB1ENR_PWREN;

    // Configure MCU low-power mode for CPU deep sleep mode

    PWR->CR |= PWR_CR_CWUF; // Clear wakeup flags
    PWR->CR |= PWR_CR_PDDS; // 0 = Stop mode, 1 = Standby mode
    PWR->CR |= PWR_CR_ULP;   // V_{REFINT} is off in low-power mode

    (void)PWR->CR; // Ensure that the previous PWR register operations have been completed


// // Configure CPU core
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // Enable CPU deep sleep mode


// Enter low-power mode
for (;;) {
__DSB();
__WFI();
}

    This topic has been closed for replies.

    3 replies

    Super User
    December 7, 2023

    Low power issues like these are discussed here frequently, try searching. @Piranha has posted lists of things to check in the past.

    JW

    ST Employee
    December 7, 2023

    Hello @Fiskk

    Most probably, the values 45-55 mA are in run mode. 

    One thing you can try is to disable the debug interface (DBGMCU) 

     

    Graduate II
    December 9, 2023

    The code seems to be adapted from my article, but it skips the part about DBGMCU_CR register.

    Also, after enabling a peripheral clock, there is a delay required before the peripheral is used:

    https://community.st.com/t5/stm32-mcus-products/erratum-quot-delay-after-an-rcc-peripheral-clock-enabling-quot/td-p/579949

    https://community.st.com/t5/stm32-mcus-embedded-software/stm32-clock-and-delay-helper-functions/td-p/593082