cancel
Showing results for 
Search instead for 
Did you mean: 

How to shorten wakeup time from STOP mode

EC.3
Associate III

Hello,

Is there any specific guidance regarding how to improve wakeup time from the various STOP modes? The U5 Reference Manual mentions that configuring STOPWUCK = 0 will use the MSIS up to 24 MHz, which would be faster than HSI16. I've used that already but am wondering if there is anything else.

I notice that when running inside the debugger STOP0 wakeup times improve by roughly 100-150us. I'm targeting 100us. Presumably that has something to do with how the DBGMCU is configured. So the MCU seems capable of waking up faster in this modified STOP0, although with lesser power savings. Still, power savings using STOP0 from within the debugger is substantially better than SLEEP outside of the debugger (meaning normal device operation). Are there other options to shorten the time, outside of DBGMCU configuration?

Thanks

10 REPLIES 10
Issamos
Lead II

Hello @EC.3 

I suggest you to disable all unnecessary peripheral before entering stop1 mode. Also, is better to reduce to the maximum the lines of code.

Best regards.

II

MikaelM
ST Employee

Hello @EC.3 

I recommend you to look at the datasheet of your device here you can find the u585 data information. If you go to chapter 5.3.7 Wake-up time from low-power modes and voltage scaling transition times 

you will find the data corresponding to twu wake up time :

MikaelM_0-1694453885733.png

So 100µs can be reach in stop 0.

note: consumption in stop0 with "debugger" is not the consumption of U5, please report as well to datasheet to know the target you can achieve according to IPs enabled.

Best regards,

Mikael

here the web site of all U5 documentation : https://www.st.com/en/microcontrollers-microprocessors/stm32u5-series/documentation.html

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

If you feel a post has answered your question, please click Accept as Solution.

Thanks for the reference to that table, @MikaelM . After looking at the listed conditions, I tried adding these lines of code:

LL_PWR_EnableFastSoftStart();
LL_PWR_EnableFlashFastWakeUp();
LL_PWR_EnableSRAM4FastWakeUp();

I used these lines 2 different ways: 1. before calling HAL_PWR_EnterSTOPMode() or 2. after it returns. Either which way, the wakeup time actually increased by about 50us. I also tried combining this with HAL_ICACHE_Disable() with similar results.

Is there a working example somewhere? If I hack it using LL_DBGMCU_EnableDBGStopMode() the time decreases by roughly 100us, which at least is going in the right direction although it's still not close to the times listed in the table.

Hello @EC.3 

You can look at the example in to Repository\STM32Cube_FW_U5_V1.3.0\Projects\NUCLEO-U575ZI-Q\Examples_LL\PWR\PWR_EnterStopMode\STM32CubeIDE

to enter stop mode 0 with LL driver.

Then you can add a simple button gpio to exit from stop mode 0 and do your time measurement (i.e. twu).

Be careful with your debugger :  this is not a "real" stop mode; prefer to do the measure outside the debugger (disconnect it), to do real measure don't use "hack" with LL_DBGMCU_EnableDBGStopMode().

Be careful in your measure, twu is the delay needed to go from a stop mode 0 state to a run mode state. It is not the delay between entering stop mode 0 and exiting stop mode 0.

One method consist in measuring power consumption (you can use a power shield board for example : https://www.st.com/en/evaluation-tools/x-nucleo-lpm01a.html 

or an stlink V3 power :https://www.st.com/en/development-tools/stlink-v3pwr.html

then you can have a good measure.

And if you just have an oscilloscope I recommend to do the following :

1/one probe on your wake up signal (gpio preferred)

2/program one gpio as ALTERNATE 15 to have access EVENTOUT signal (second probe here)

MikaelM_0-1694511023109.png

3/if you use WFE => then the first instruction executed after is SEV ==> you will have the time twu between your 2 oscilloscope probes.

4/If you use WFI => you can toggle a gpio in your ISR (but some delays added)

5/ or do the following :

disable all irq

WFI()

enable irq

==> the SEV will be executed just after the WFI

I recommend you to also have a look at : https://wiki.st.com/stm32mcu/wiki/Getting_started_with_PWR

best regards

Mikael

If you feel a post has answered your question, please click Accept as Solution.

I found a PWR_EnterStandbyMode project in the same folder as the PWR_EnterStopMode project you mentioned. I got that one running - it happens to use a button to wakeup out of STANDBY. However, when I change LL_PWR_SetPowerMode( LL_PWR_STANDBY_MODE ) to LL_PWR_SetPowerMode( LL_PWR_STOP0_MODE ) it will no longer wake up. Even though STOP0 does not require the use of one of the 24 wakeup pins, I would've thought that 1 change would work as any EXTI should wake it up from STOP0.

I was able to wakeup from STOP0 in my original app, which uses HAL functions instead of LL functions like the example. I'm not yet measuring anything so I didn't disable interrupts, as you mentioned in option #5 in your list. Why wouldn't this work - it's a pretty straightforward change?

EC.3
Associate III

...it's because STANDBY comes back up from a brownout reset so it's reinitializing - making my interpretation of GPIO behavior incorrect. Yeah, I'll need to spend some more time modifying the example...

hello @EC.3 

I propose you to take time to define what is the requirements of your project in term of consumptions and then in term of wake up time, because the more deeply you "sleep" your device, the most of time to wake up you will need.

From your first post, your needs was to reduce the wake up time under 100µs in stop 0 mode (my understanding, but maybe I'm wrong). So it can be possible according to datasheet.

Be careful by doing several different trials with stop mode 0/1/2/3, standby, shut down because behaviors are not the same and before changing it you have to well understand the advantages and the drawbacks depends on your requirements.

Best regards

Mikael

If you feel a post has answered your question, please click Accept as Solution.

Hello @MikaelM 

So I have the PWR_EnterStopMode example using a user button for wakeup, along with __WFE(). I'm using a logic analyzer @ 100MS/s to observe the "LED" toggle output (not an actual LED on my board, just an output), the button used for wakeup, and PA5 which I'm trying to use as EVENTOUT. I can see the button press edge followed by the LED, but no activity on PA5. Seems like there something I need to do in addition to the code below to hook PA5 to the SEV event, but I don't know what that is:

GPIO_InitStruct.Pin = LL_GPIO_PIN_5;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_15;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

I also tried explicitly adding __SEV() after __WFI(), but still no output was observed.

Hello @EC.3 

Please try this :

in main() between  /* USER CODE BEGIN 1 */ and  /* USER CODE END 1 */

LL_GPIO_InitTypeDef GPIO_InitStruct= {0};

__HAL_RCC_GPIOA_CLK_ENABLE();
LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5);
GPIO_InitStruct.Pin = LL_GPIO_PIN_5;

GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.OutputType= LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

then at the position where you call stop mode :

LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFE);
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_5);
 

So in that case, PA5 will be set high just after wakeup (some clock delays but it's acceptable). And then you will be able to see on an oscilloscope the delay between you push button and the PA5 signal.

if you want to use WFI :

define this :

#define CRITICAL_SECTION_BEGIN( ) uint32_t primask_bit= __get_PRIMASK();\
                                                                 __disable_irq()
#define CRITICAL_SECTION_END( ) __set_PRIMASK(primask_bit)

then 

CRITICAL_SECTION_BEGIN();

LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_5);

 CRITICAL_SECTION_END();

then the gpio PA5 signal will be executed just before your push button ISR execution.

Best regards

Mikael

 

If you feel a post has answered your question, please click Accept as Solution.