cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L072 Standby Mode problems

Fiskk
Associate

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();
}

3 REPLIES 3

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

JW

Sarra.S
ST Employee

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) 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Piranha
Chief II

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