Skip to content
Snippets Groups Projects
Commit 547089f2 authored by Per's avatar Per
Browse files

standby 3uA

parent 31dff2f6
No related branches found
No related tags found
No related merge requests found
...@@ -82,6 +82,31 @@ ...@@ -82,6 +82,31 @@
}, },
"cwd": "${workspaceRoot}" "cwd": "${workspaceRoot}"
}, },
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"name": "standby (release)",
"executable": "./target/thumbv7em-none-eabihf/release/examples/standby",
"configFiles": [
"interface/stlink.cfg",
"target/stm32f4x.cfg"
],
"swoConfig": {
"enabled": true,
"cpuFrequency": 8000000,
"swoFrequency": 2000000, // you may try 1000000 if not working
"source": "probe",
"decoders": [
{
"type": "console",
"label": "Name",
"port": 0
}
]
},
"cwd": "${workspaceRoot}"
},
{ {
"type": "cortex-debug", "type": "cortex-debug",
"request": "launch", "request": "launch",
......
...@@ -34,16 +34,54 @@ extern crate stm32f40x; ...@@ -34,16 +34,54 @@ extern crate stm32f40x;
extern crate cortex_m_rt as rt; extern crate cortex_m_rt as rt;
// makes `panic!` print messages to the host stderr using semihosting // makes `panic!` print messages to the host stderr using semihosting
extern crate panic_semihosting; // extern crate panic_semihosting;
extern crate panic_abort;
use cortex_m::asm; use cortex_m::asm;
use rt::ExceptionFrame; use rt::ExceptionFrame;
use cortex_m::peripheral::{Peripherals, SCB};
use stm32f40x::DBG;
// the program entry point is ... // the program entry point is ...
entry!(main); entry!(main);
// ... this never ending function // ... this never ending function
fn main() -> ! { fn main() -> ! {
// let scb = p.core.SCB;
asm::bkpt();
let mut p = Peripherals::take().unwrap();
p.SCB.set_sleepdeep();
let mut r = stm32f40x::Peripherals::take().unwrap();
let v = r.DBG.dbgmcu_cr.read();
r.DBG.dbgmcu_cr.modify(|_, w| {
w.dbg_sleep()
.clear_bit()
.dbg_stop()
.clear_bit()
.dbg_standby()
.clear_bit()
});
let v1 = r.DBG.dbgmcu_cr.read();
asm::bkpt();
// enable pwr
r.RCC.apb1enr.modify(|_, w| w.pwren().set_bit());
// standby mode
r.PWR
.cr
.modify(|_, w| w.pdds().set_bit().cwuf().clear_bit());
// // pwr.cr.modify(|_, w| w.lpds().clear_bit()); // regulator in normal mode
// pwr.cr.modify(|_, w| w.lpds().set_bit()); // regulator in low power mode
// exti.pr.write(|w| unsafe { w.bits(0) }); // clear pending register
// pwr.csr.modify(|_, w| w.ewup().set_bit()); // clear pending wake up
asm::bkpt();
loop { loop {
asm::wfi(); asm::wfi();
asm::bkpt(); asm::bkpt();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment