In this video, we explore different "deep sleep" methods on the Raspberry Pi Pico RP2040. By putting the processor into a "deep sleep" we can use less power during times where executing code isn't important. Deep sleep on the RP2040 allows us to use less power and ultimately make our Raspberry Pi Pico projects way more efficient.
Check out my channel for more videos like this on the Raspberry Pi Pico, ARM Assembly, debugging, and much much more!
Buy the RP2040: [ Ссылка ]
Chapters
0:00 Intro
0:11 Baseline
1:10 Sleep?
1:49 How Does Sleep Work?
2:38 Deep Sleep Library
3:00 RTC Alarm Sleep
4:44 Rising Edge Deep Sleep
6:39 Outro
#raspberrypi #raspberrypipico #rp2040
Join us on Discord: [ Ссылка ]
===
yeah and you'll see here the results are pretty disappointing actually we lose a little bit of current which means that the power has gone down a little bit but we're still pulling in the same amount of power as just no opting in a loop so you gotta ask why does that happen well let's dive into the instructions of the actual sleep code and see how that works so here we are in the picosdk we're actually at the code that executes the sleep ms function sleep ms is just sleep milliseconds and it ends up just calling sleep microseconds with your time times a thousand if you go to the sleep microseconds function that is just a sleep until function if alarm pools are not disabled which they're not by default and then if you actually go into the code after a couple checks get done to see if you've gotten to the point where you should be done sleeping the code is just the wfe micro instruction which is an assembly instruction in c um and wfe is just wait for event which executes as a knob on the target so again our sleep functionality which you would think gives you lower power consumption faster code execution while sleeping no it's just a knob now when i was making this video i was starting to get really disappointed because i felt like there was no code in the pico sdk library that actually implemented the deep sleep functionality of the arm cortex processor but then in looking around i discovered that raspberry pi put out this extra library literally called pico extras and it exports this sleep interface and the sleep interface has some functionality one of them is a sleep go to sleep until where you can specify a real-time counter alarm and a callback to execute once the alarm has gone off and within this api they actually use the deep sleep functionality of the processor and you'll see here in a second the power consumption is significantly lower so basically what this code does here i'll kind of walk y'all through it we turn the processor on it is not awake we put it into real-time clock sleep we basically say that this is the date now and then we say that this is the time we want to wake up which is just this previous date 10 seconds later we initialize the real time clock and then we set the date time to the time we say it is and then we say go to sleep until this alarm goes off and when it goes off execute the sleep call back the sleep callback just says the global variable awake is true and what that does for us is that means that we should never get here because we should be sleeping until we are awake
===
Ещё видео!