STM32 many power saving modes - Page 1
Forum section: electronics / projects

author: Wilson__
author_rank: Frequent Contributor
timestamp: May 20, 2024, 06:11:34 pm
content: New to STM32. Anyenlightenment commenton how to choose betweenSleep mode, Low-power run mode, Low-power sleep mode, Stop 0, Stop 1, Stop 2 and Standby modes.The application aims for long cell life. Processsing is relatively simple, get work done and back to 'sleep' ASAP but there are many 'sleep' modes to chooseMany thanks

author: uer166
author_rank: Super Contributor
timestamp: May 20, 2024, 07:53:36 pm
content: This is a function entirely on what autonomous peripherals you need to run.It runs the full range of "everything is on except CPU", to "no clock in chip at all, and only an external rising edge can wake it".Generally I've had good luck making the first or second steps work well in STM32U5 with autonomous DMA, ADC readings, and SPI/UART transfers while CPU sleeps.The deeper the sleep the less things work and the harder it is to implement.

author: Tation
author_rank: Regular Contributor
timestamp: May 20, 2024, 10:29:49 pm
content: Usually there is a table in thereference manualdatasheetdescribing what is powered, what is clocked, how to enter into, and how to exit from, each power saving mode.Just select the most suitable mode for your application. Or start from the easiest modes and advance thru them until satisfied. "Advanced" sleep modes pose many constraints in the mechanisms able to wake up the chip.

author: Tation
author_rank: Regular Contributor
timestamp: May 21, 2024, 07:20:24 am
content: Like below.

author: hans
author_rank: Super Contributor
timestamp: May 21, 2024, 07:35:05 am
content: The "Run" mode is the typical running mode which allows for the highest clocks. It may have various core voltage levels applied to the core which can save a bit of power or achieve the highest clock speed.If you don't need a high clock speed you can use low-power run. On most parts where I see this featured, the limit is usually around 2-4MHz or so. On STM32L4 and other parts, it switches to a lower power regulator. Similarily, this lower power regulator is also used for sleep durations. This mode is useful if you need the MCU to remain active for long periods of time without fast responses. The low power STM32s also feature a MSI oscillator which you can scale down to tens or hundreds of kHz without paying a large biasing current of a high-speed crystal/oscillator. I used this mode on STM32L4 to run the part at 100kHz for long durations.In STM32 world, the term "sleep" is a bit confusing though, because it only refers to the CPU not executing instructions. The rest of the peripheral world keeps running as-is. Personally I would refer to this as an idle state, but whatever.The various stop modes scales down the peripheral domain. FLASH is often disabled as it is not expected the CPU needs to quickly resume running code. High-power peripherals (like USB or ethernet) may be disabled as well, then high freq clocks and eventually only a limited subset of low frequency peripherals (e.g. a LPTIM) can remain active.Then at the low end of operational modes is standby, which is probably the more classic meaning of 'sleep'. This mode typically only has brownout and RTC running, that's it.The STM32U5 chip is a bit unique, as it features a Smart Run Domain in which it can request a clock on-demand for high-frequency peripherals, even in STOP0-2 (iirc it even features STOP3). This is a feature that was long overdue as MSP430 and SiLabs chips had this for quite some time.By having clocks on-demand, there is less need for a LPRun/LPSleep mode that keeps high-frequency oscillators active. The code can 'race to sleep' again, which is typically a good strategy to save energy.However if you're concerned with battery life, total energy draw (as opposed to power) are things to consider. High current spikes don't always help, so that could compromise the chosen clockspeed.

author: Wilson__
author_rank: Frequent Contributor
timestamp: May 21, 2024, 04:56:41 pm
content: Many thanks for advises.Does it matter to run STM32 at full speed at 4 mA to process the job quickly and get back to sleep ASAP?Cell life consumption, by the CPU core, will be 4mA x run time to consume mAh rating of the cell.If run at half speed, it will take double time and resulting in same mAh number for the CPU core consumption. Doubling run time means peripheral (GPIO and SPI in our case) are clocked for longer time, wasting energy while waiting for the CPU to send it data.4mA is well below cell discharge ceiling of 1C so not significantly regrade cell mAh rating. I mean, cell has less mAh when discharge at 1C vs at 0.05C.Many thanks

author: thm_w
author_rank: Super Contributor
timestamp: May 21, 2024, 11:39:55 pm
content: Quote from: Wilson__ on May 21, 2024, 04:56:41 pmYou answered your own question.You can see in the chart above the consumption is ~90uA/MHz.QuoteSo half speed is half power but 2x run time, which you don't want.In reality if it actually matters to this degree, you'd end up doing some real world testing and optimizing.

author: hans
author_rank: Super Contributor
timestamp: May 23, 2024, 07:02:18 am
content: QuoteTo give a somewhat complete answer; it depends.If the wake time depends on I/O, then you want the processor to just run fast enough to keep up. This is what I explained earlier about LPRun and a project where I only needed 100kHz. That thing was sampling slow radio signals and potentially waiting for hundreds of ms to find a preamble to lock on to. But other buses could also be slow.. like UARTs or I2C buses.100kHz is by far not the best uA/MHz sweetspot though, as biasing of oscillators, voltage regulators remains fairly constant. If your code is mostly dependant on processing, then you'll want the most efficient operating point of the MCU, and that is often at higher speeds. Don't forget to optimize the written code with a balanced or speed compiler profile.However, going as high clockspeed as possible also necessarily doesn't have to be the most efficient (see how desktop CPUs overheat for the last 100-200MHz clock speeds). ST has very comprehensive supply current measurements in their datasheets for virtually all their parts.. (sometimes also running various programs like CoreMark, while(1), etc). Of course it can't list everything but I think most parts I've seen it lists like a dozen or more different clock speeds at which a current measurement was made. Take the ratio and you can find a sweetspot.Sometimes another thing to consider is current spikes on a battery cell. What cell are you using? E.g. a CR2032 has an ESR of a few Ohms and starts to get higher as the cell gets discharged. Drawing a few mA from it can cause quite significant voltage droops, and waste some portion of energy inside the cell (although this is probably within the single-digit % margins). The same could be true for supercaps with high ESR.