2023-06-28 12:06 PM
Hi, I have a problem entering Stop Mode 2 with STM32L451CCU6. My current consumption is around 600 uA, while expected should be much lower. What can cause this problem? Here is the code:
use cortex_m::asm;
use cortex_m_rt::entry;
use stm32l4xx_hal::{prelude::*, pwr};
#[entry]
fn main() -> ! {
let mut cp = stm32l4xx_hal::pac::CorePeripherals::take().unwrap();
let mut dp = stm32l4xx_hal::pac::Peripherals::take().unwrap();
unsafe {
dp.PWR.cr1.write(|w| w.lpms().bits(0b010));
}
let mut rcc = dp.RCC.constrain();
let mut pwr = dp.PWR.constrain(&mut rcc.apb1r1);
let mut flash = dp.FLASH.constrain();
let clocks = rcc.cfgr.sysclk(80.MHz()).freeze(&mut flash.acr, &mut pwr);
cp.SCB.set_sleepdeep();
cp.SYST.disable_interrupt();
asm::dsb();
loop {
asm::wfi();
}
}