-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Going into dormant state #659
Comments
Hello, 20mA seem to be quite a lot as the bootsel mode typically runs around 14mA. From reading the rp2040 datasheet, it seems to me that core1 enters deepsleep at boot (WFE + SCR.SLEEPDEEP set). Based on what I can see from the listed source, the dormant mode is not linked to deepsleep/WFI/WFE. Anyways, I should have started with this: The |
Thank you. I will look into that and make sure to submit a PR if I end up writing recovery logic 🙂 |
So I've gotten around to play with this now and at the moment I haven't even been able to put the Pico into a deep sleep where it consumes less than 8mA, which is still quite a lot. The examples in pico-extras and in the sdk are kind of confusing. However some of the examples disable the xosc outright, and some put it into dormant mode. So I'm not quite sure what I'm doing wrong - my setup and codes as follows:
I'm not initializing the PLLs nor am I configured any of the other clocks, so as far as I understand I shouldn't need to stop them explicitly. So far I've tried -
Of course non of these are meant to be recoverable at the moment - just trying to go into deep sleep. This is my code: #![no_std]
#![no_main]
use bsp::entry;
use defmt_rtt as _;
use embedded_hal::digital::v2::OutputPin;
use panic_halt as _;
use rp_pico as bsp;
use bsp::hal::{
clocks::{Clock, ClocksManager, ClockSource, StoppableClock},
pac,
sio::Sio,
watchdog::Watchdog,
pll::{
common_configs::{PLL_SYS_125MHZ, PLL_USB_48MHZ},
setup_pll_blocking, Error as PllError, Locked, PhaseLockedLoop,
},
};
use fugit::{HertzU32, RateExtU32};
#[entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let core = pac::CorePeripherals::take().unwrap();
let sio = Sio::new(pac.SIO);
let external_xtal_freq_hz = 12_000_000u32;
let xosc = bsp::hal::xosc::setup_xosc_blocking(pac.XOSC, external_xtal_freq_hz.Hz()).unwrap();
let mut clocks = ClocksManager::new(pac.CLOCKS);
clocks.system_clock.configure_clock(&xosc, xosc.get_freq()).unwrap();
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());
let pins = bsp::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let mut led_pin = pins.led.into_push_pull_output();
for i in 0..5 {
led_pin.set_high().unwrap();
delay.delay_ms(500);
led_pin.set_low().unwrap();
delay.delay_ms(500);
}
// Halt forever
unsafe {
let SCB_SCR_SLEEPDEEP: u32 = 0x1 << 2;
(*pac::SCB::PTR).scr.modify(|scr| scr | SCB_SCR_SLEEPDEEP);
xosc.disable();
//xosc.dormant();
}
loop {
cortex_m::asm::wfi();
}
} |
Hello, I got it to go to deepsleep and wake from it. I don't have any power measurement tool accurate enough to see any consumption at all (it must always be <1mA at 5V, or my tool is really crappy). I'll continue trying to identify the issues under this in the coming days. |
Actually, I wasn't far from making it work: https://github.com/ithinuel/hello-dormant-rp2040 As mentionned before, I don't have the tools to measure power consumption. |
I got hold of a power measurement tool and I can confirm that I get power usage consistent with the rp-pico's datasheet: https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf According to the datasheet, the rtc is required to take its input clock from an external pin to allow for waking from Dormant mode. Another limitation I found is that the rp2040-hal lacks the ability to recover from that dormant mode and the clock object gets consumed in the process, so one cannot re-enter dormant after waking up. This PR should cover the needs for deep-sleep: Last edit: 28/08/23 23:53 BST. |
Amazing, thank you. |
Hi, in my application I'd like the RP2040 to completely power off in certain cases, so it consumes minimal current.
According to several sources its possible to go into a dormant state in which the power consumption is <1mA.
Ive looked around and it seems this involves disabling interrupts and then disabling several of the system clocks.
I also saw this PR #613 which seems to have a halt function, but that doesnt put the main core to sleep as far as I could tell. Using WFE/WFI even with interrupts disabled still puts my Pico at ~20mA of draw. A timer sleep puts it at around 9mA.
Is there any way using the existing HAL code to go into deep sleep?
The text was updated successfully, but these errors were encountered: