2023-12-06 06:24 AM
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();
}
2023-12-06 11:18 PM
Low power issues like these are discussed here frequently, try searching. @Piranha has posted lists of things to check in the past.
JW
2023-12-07 12:37 AM
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.
2023-12-08 06:57 PM
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: