cancel
Showing results for 
Search instead for 
Did you mean: 

Enter low power run mode directly at boot

Kemsa
Associate II

Hello community,

 

I have this difficult task of powering an STM32G0B1 from a pin that was really not tasked for that (because the connector I have to plug onto provides no supply pin). In short, I can't draw more than 500µA current at any time or I risk lowering the voltage too much for MCU.

I have tried so far to reduce clock and use low power run mode. I get a power consumption around 300µA, which is good enough for me. The problem is that the current drawn at boot before entering low power mode is around 1mA for about 30ms, as you can see on oscilloscope below (1mV=1µA)

WhatsApp Image 2025-01-28 à 11.17.07_4025050e.jpg


Is it possible to start program directly in low power mode without ever entering "normal" mode?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Is it possible to start program directly in low power mode without ever entering "normal" mode?

No. Chip always boots to normal mode.

You can see the entry conditions for low power mode here. All of them involve doing something after the chip is in run mode.

TDK_0-1738071564426.png

 

You can enter a low power mode immediately (< 1 ms) upon start if you do it right at ResetHandler, though this will involve breaking the normal startup routine that CubeMX uses.

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

View solution in original post

9 REPLIES 9
TDK
Guru

Is it possible to start program directly in low power mode without ever entering "normal" mode?

No. Chip always boots to normal mode.

You can see the entry conditions for low power mode here. All of them involve doing something after the chip is in run mode.

TDK_0-1738071564426.png

 

You can enter a low power mode immediately (< 1 ms) upon start if you do it right at ResetHandler, though this will involve breaking the normal startup routine that CubeMX uses.

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

BTW: What about to use capacitor to supply MCU during startup ? For example 220uF capacitor drops from 3.3V to 3.0V after 50ms if source current 1mA. And can be charged from 0V to 3.3V in less then two seconds.

That's the solution we are trying right now. But because it's a pin we are highjacking that is used for another purpose, we must first delay input, set MCU behind a delayed mosfet and so far, the large capa doesn't play nice with mosfet (smaller ones are fine, but not enough capa...)

Kemsa
Associate II

Thanks for your reply @TDK . It is as I feared...Although 1ms instead of 30ms might be enough for capas to fill the necessary current.

Where would you change the reset handler? I have no experience with that so far...
Restoring the changes after each re-generation by cubeMX would be an acceptable compromise. 

Looks like SystemInit is called immediately after startup, so put the clock initialization there or put it in another function and jump to it (bl) before SystemInit.

 

Here's the first part of the startup code.

 

Reset_Handler:  
  ldr   sp, =_estack    		 /* set stack pointer */

/* Call the clock system initialization function.*/
  bl  SystemInit   

/* Copy the data segment initializers from flash to SRAM */  
  ldr r0, =_sdata
  ldr r1, =_edata
  ldr r2, =_sidata
  movs r3, #0
  b LoopCopyDataInit

CopyDataInit:
  ldr r4, [r2, r3]
  str r4, [r0, r3]
  adds r3, r3, #4
...

 

 

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

Hello,
I tried to set low power mode as soon as possible, just after reset, but I see no improvement to current peak duration when I power up processor @TDK .
Here is my code modification. Debugging tells me I go through the code allright before going to main.

Reset_Handler:
  ldr   r0, =_estack
  mov   sp, r0          /* set stack pointer */

/*Call low power mode */
  bl HAL_PWREx_EnableLowPowerRunMode

/* Call the clock system initialization function.*/
  bl  SystemInit

/* Copy the data segment initializers from flash to SRAM */
  ldr r0, =_sdata
  ldr r1, =_edata
  ldr r2, =_sidata
  movs r3, #0
  b LoopCopyDataInit

This code can't work. You need to lower the clock below 2 MHz before entering low power run mode. When the chip boots, the clock is 16 MHz.

TDK_0-1738248163977.png

 

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

Oh yes, indeed. I'm so used to having cubeMX doing it for me that I forget when I need to set it up manually.

Kemsa
Associate II

Hello again,
After some trials, I was able to boot my MCU, thanks in part to larger capas, although I wasn't able to solve the initial 30ms power spike. I believe it is the "reset state" that just takes 30ms, because when I push the reset button, I get the same current consumption and MCU almost immediately goes to low power mode when I release the button/