STM32F030RCT high power consumption in sleep modes?

Post here first, or if you can't find a relevant section!
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32F030RCT high power consumption in sleep modes?

Post by STM32ardui »

Mangy_Dog wrote: Tue Jul 30, 2024 8:20 pm Deepsleep is a feature in the Low Power library bundled with stm32.
Then you should take a look into the source code of the library.
I guess: so called "deep sleep" = stop mode
Mangy_Dog wrote: Mon Jul 29, 2024 12:58 pm Is there anything else I can do to get this into a deeper deeper sleep?
Yes.
User ag123 already told you: switch power off!

What kind of help do you expect, if you tell nothing about your project???
ag123
Posts: 1898
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: STM32F030RCT high power consumption in sleep modes?

Post by ag123 »

I think power consumption varies between soc, if the 4mA isn't consumed by any other thing than the SOC itself, try a different board.
Maybe that alone would make a difference.

Oh yes, there is one more thing, unclock *all* the peripherals, practically shutdown everything gpio/adc/timers/spi/i2c/usb/uart etc on the APB bus, maybe that's where the power consumption is going, setting a gpio to output and if that is sinking or sourcing current can easily account for 4mA currents (e.g. sinking 3.3v across a 1k resistor is already 3.3mA).

sleep/deepsleep etc only affects the cpu core, the peripherals can still be running hot draining amperes of current.
User avatar
Mangy_Dog
Posts: 124
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: STM32F030RCT high power consumption in sleep modes?

Post by Mangy_Dog »

STM32ardui wrote: Wed Jul 31, 2024 3:32 am
Mangy_Dog wrote: Tue Jul 30, 2024 8:20 pm Deepsleep is a feature in the Low Power library bundled with stm32.
Then you should take a look into the source code of the library.
I guess: so called "deep sleep" = stop mode
Mangy_Dog wrote: Mon Jul 29, 2024 12:58 pm Is there anything else I can do to get this into a deeper deeper sleep?
Yes.
User ag123 already told you: switch power off!

What kind of help do you expect, if you tell nothing about your project???
You know you really could do with being a little less antagonistic.
I'm not new here, and I'm not new to stm32 development.

I cant go into more details about the board because its a prototype for a mass production product.

The chip was selected before I came on board. I would have selected an L series if possible. But I am trying to make this chip meet expectations for the company...

So yeah want to help great, want to be an ass? Kindly go someplace else.
Just a dogs body developer, mostly making props and stuff...
User avatar
Mangy_Dog
Posts: 124
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: STM32F030RCT high power consumption in sleep modes?

Post by Mangy_Dog »

ag123 wrote: Wed Jul 31, 2024 4:05 am I think power consumption varies between soc, if the 4mA isn't consumed by any other thing than the SOC itself, try a different board.
Maybe that alone would make a difference.

Oh yes, there is one more thing, unclock *all* the peripherals, practically shutdown everything gpio/adc/timers/spi/i2c/usb/uart etc on the APB bus, maybe that's where the power consumption is going, setting a gpio to output and if that is sinking or sourcing current can easily account for 4mA currents (e.g. sinking 3.3v across a 1k resistor is already 3.3mA).

sleep/deepsleep etc only affects the cpu core, the peripherals can still be running hot draining amperes of current.
Hmm good point, I've already tried shutting clocks down, but it seems deepsleep is already doing that anyway so it didnt make any difference.
Most of the pins are floating in this test code.
When you say shut down the GPIOs, what way do you mean? Setting to OUTPUT (non sinking mode) and pulling low? Set to float?

Also wouldnt disabling the various clocks effectively shutdown SPI i2c and uart? IE this code...

Code: Select all

void DeeperSleep (uint32_t timeMS)
{
  //turning off as many clocks as possible before going to deep sleep. Needs reenabling when woken.
  //Should help reduce sleep power consumption to the uA
  __HAL_RCC_USART1_CLK_DISABLE();
  __HAL_RCC_USART2_CLK_DISABLE();
  __HAL_RCC_USART3_CLK_DISABLE();
  __HAL_RCC_USART4_CLK_DISABLE();
  __HAL_RCC_USART5_CLK_DISABLE();
  __HAL_RCC_USART6_CLK_DISABLE();

  __HAL_RCC_SPI1_CLK_DISABLE();
  __HAL_RCC_SPI2_CLK_DISABLE();

  __HAL_RCC_I2C1_CLK_DISABLE();
  __HAL_RCC_I2C2_CLK_DISABLE();

  __HAL_RCC_ADC1_CLK_DISABLE();

  __HAL_RCC_TIM1_CLK_DISABLE();
  __HAL_RCC_TIM3_CLK_DISABLE();
  __HAL_RCC_TIM6_CLK_DISABLE();
  __HAL_RCC_TIM7_CLK_DISABLE();
  __HAL_RCC_TIM14_CLK_DISABLE();
  __HAL_RCC_TIM15_CLK_DISABLE();
  __HAL_RCC_TIM16_CLK_DISABLE();
  __HAL_RCC_TIM17_CLK_DISABLE();

  __HAL_RCC_GPIOA_CLK_DISABLE();
  __HAL_RCC_GPIOB_CLK_DISABLE(); // might still be able to wake on EXT1 if switched off.
  __HAL_RCC_GPIOC_CLK_DISABLE();
  __HAL_RCC_GPIOD_CLK_DISABLE();

  __HAL_RCC_CRC_CLK_DISABLE();

  __HAL_RCC_DMA1_CLK_DISABLE();

  // Enter low-power sleep mode using LowPower library
  LowPower.deepSleep (timeMS);

}
Just a dogs body developer, mostly making props and stuff...
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: STM32F030RCT high power consumption in sleep modes?

Post by STM32ardui »

Mangy_Dog wrote: Wed Jul 31, 2024 8:49 am
STM32ardui wrote: Wed Jul 31, 2024 3:32 am What kind of help do you expect, if you tell nothing about your project???
You know you really could do with being a little less antagonistic.
I'm not new here, and I'm not new to stm32 development.

I cant go into more details about the board because its a prototype for a mass production product.

So yeah want to help great, want to be an ass? Kindly go someplace else.
You should be careful to call me an ass!
And nothing of my hint, that it is difficult to help someone without knowing what he's doing, is antagonistic.

And it can't be a secret to tell other users, how many minutes MCU is working, how long sleeping, if you are reading analog values by ADC or using sensors via I2C. Is RTC still running or not. Has memory to be retained etc.


BTW: never leave GPIOs floating!
---> AN4899 "STM32 microcontroller GPIO hardware settings and low-power consumption"

ST offers datasheets and reference manuals about each MCU. And if they publish values for sleep and stop mode, these values are correct. So problem must be your board. If you are not allowed to share schematic, how can other users help you???
User avatar
Mangy_Dog
Posts: 124
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: STM32F030RCT high power consumption in sleep modes?

Post by Mangy_Dog »

STM32ardui wrote: Wed Jul 31, 2024 10:28 am
Mangy_Dog wrote: Wed Jul 31, 2024 8:49 am
STM32ardui wrote: Wed Jul 31, 2024 3:32 am What kind of help do you expect, if you tell nothing about your project???
You know you really could do with being a little less antagonistic.
I'm not new here, and I'm not new to stm32 development.

I cant go into more details about the board because its a prototype for a mass production product.

So yeah want to help great, want to be an ass? Kindly go someplace else.
You should be careful to call me an ass!
And nothing of my hint, that it is difficult to help someone without knowing what he's doing, is antagonistic.

And it can't be a secret to tell other users, how many minutes MCU is working, how long sleeping, if you are reading analog values by ADC or using sensors via I2C. Is RTC still running or not. Has memory to be retained etc.


BTW: never leave GPIOs floating!
---> AN4899 "STM32 microcontroller GPIO hardware settings and low-power consumption"

ST offers datasheets and reference manuals about each MCU. And if they publish values for sleep and stop mode, these values are correct. So problem must be your board. If you are not allowed to share schematic, how can other users help you???
So how many companies have you worked for that they let you just post schematics of company projects on an open forum?

"You should be careful to call me an ass!" Mate, dont start being a threatening keyboard warrior with me. On that line alone im just going to start muting you.

And yes thank you I have extensively been going through the datasheet. I still would like to see if theres any undocumented ways to reduce power

And as for NEVER LEAVE PINS FLOATING.... well... what do you think a unprogrammed MCU is going to do?
Just a dogs body developer, mostly making props and stuff...
User avatar
Mangy_Dog
Posts: 124
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: STM32F030RCT high power consumption in sleep modes?

Post by Mangy_Dog »

Capture.PNG
Capture.PNG (88.53 KiB) Viewed 4598 times
So yeah I should be able to hit sub 1mA
Just a dogs body developer, mostly making props and stuff...
ag123
Posts: 1898
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: STM32F030RCT high power consumption in sleep modes?

Post by ag123 »

Mangy_Dog wrote: Wed Jul 31, 2024 9:23 am
Hmm good point, I've already tried shutting clocks down, but it seems deepsleep is already doing that anyway so it didnt make any difference.
Most of the pins are floating in this test code.
When you say shut down the GPIOs, what way do you mean? Setting to OUTPUT (non sinking mode) and pulling low? Set to float?
shutdown gpios has 2 possible steps, setting them to pinMode(pin, INPUT) is one, setting it to OUTPUT, if it is low it is sinking currents and if it is high it is sourcing currents, e.g. if you happened to have a resistor connecting VDD to the pin and it is OUTPUT (e.g. a pull up resistor) chances are that current is flowing. (e.g. the I2C pull up resistor)
The more extreme step is to un-clock the gpio subsystem, effectively shutting it down, this would be a bit extreme unless every microamp matters.
Also wouldnt disabling the various clocks effectively shutdown SPI i2c and uart? IE this code...

Code: Select all

void DeeperSleep (uint32_t timeMS)
{
  //turning off as many clocks as possible before going to deep sleep. Needs reenabling when woken.
  //Should help reduce sleep power consumption to the uA
  __HAL_RCC_USART1_CLK_DISABLE();
  __HAL_RCC_USART2_CLK_DISABLE();
  __HAL_RCC_USART3_CLK_DISABLE();
  __HAL_RCC_USART4_CLK_DISABLE();
  __HAL_RCC_USART5_CLK_DISABLE();
  __HAL_RCC_USART6_CLK_DISABLE();

  __HAL_RCC_SPI1_CLK_DISABLE();
  __HAL_RCC_SPI2_CLK_DISABLE();

  __HAL_RCC_I2C1_CLK_DISABLE();
  __HAL_RCC_I2C2_CLK_DISABLE();

  __HAL_RCC_ADC1_CLK_DISABLE();

  __HAL_RCC_TIM1_CLK_DISABLE();
  __HAL_RCC_TIM3_CLK_DISABLE();
  __HAL_RCC_TIM6_CLK_DISABLE();
  __HAL_RCC_TIM7_CLK_DISABLE();
  __HAL_RCC_TIM14_CLK_DISABLE();
  __HAL_RCC_TIM15_CLK_DISABLE();
  __HAL_RCC_TIM16_CLK_DISABLE();
  __HAL_RCC_TIM17_CLK_DISABLE();

  __HAL_RCC_GPIOA_CLK_DISABLE();
  __HAL_RCC_GPIOB_CLK_DISABLE(); // might still be able to wake on EXT1 if switched off.
  __HAL_RCC_GPIOC_CLK_DISABLE();
  __HAL_RCC_GPIOD_CLK_DISABLE();

  __HAL_RCC_CRC_CLK_DISABLE();

  __HAL_RCC_DMA1_CLK_DISABLE();

  // Enter low-power sleep mode using LowPower library
  LowPower.deepSleep (timeMS);

}
yes disabling the various clocks effectively *switch off* the entire subsystem, and you would need to setup clocks again and re-initialise every peripheral on resume / wakeup. It is practically *switch off* the whole system. This would help if your intended 'deep sleep' is practically *switch off* and a toggle e.g. 'switch on' is good as a full power cycle and initialize everything from scratch.

I'd use this if I intended to do 'soft' power off, i.e. press a toggle tactile button to power off, and toggle again to power on.
But that this can be useful in automation scenarios if that 'toggle on' has enough time for you to bootstrap from completely off to on and perhaps handle the event.

I'd guess a short cut to doing this is when waking up from deep sleep is to do a NVIC_System_reset() and practically 'reboot'

There is one thing you can use to keep state across resets, they are the backup registers, sram is cleared but that backup registers keep values.
some stm32 socs has backup memory which can store even more data.

my own habit with power is that if possible keep it running connected to power e.g. a usb phone charger.
if not use a large battery e.g. a usb power bank or lipo batteries
and to 'save power', I tend to place

Code: Select all

asm("wfi"); //wait for systick
at the bottom of loop(), that makes loop() run every millisecond and I've observed that the cpu/soc runs at a lower temperature, thus saving power, by simply doing this.

I tend to think 'deep sleep' etc is 'too much hassle' as one'd need to think about 'keeping state between standby/resets', it is easier to cause bugs that way.
GonzoG
Posts: 491
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: STM32F030RCT high power consumption in sleep modes?

Post by GonzoG »

It is called like this, but it's a "normal" sleep mode. Barely any reduction in power as everything stays powered on.

If you want it to go down to uA range, you need to put MCU into standby mode - use shutdown().
f030cb_power.png
f030cb_power.png (48.69 KiB) Viewed 4551 times
User avatar
Mangy_Dog
Posts: 124
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: STM32F030RCT high power consumption in sleep modes?

Post by Mangy_Dog »

ag123 wrote: Wed Jul 31, 2024 11:32 am
Mangy_Dog wrote: Wed Jul 31, 2024 9:23 am
Hmm good point, I've already tried shutting clocks down, but it seems deepsleep is already doing that anyway so it didnt make any difference.
Most of the pins are floating in this test code.
When you say shut down the GPIOs, what way do you mean? Setting to OUTPUT (non sinking mode) and pulling low? Set to float?
shutdown gpios has 2 possible steps, setting them to pinMode(pin, INPUT) is one, setting it to OUTPUT, if it is low it is sinking currents and if it is high it is sourcing currents, e.g. if you happened to have a resistor connecting VDD to the pin and it is OUTPUT (e.g. a pull up resistor) chances are that current is flowing. (e.g. the I2C pull up resistor)
The more extreme step is to un-clock the gpio subsystem, effectively shutting it down, this would be a bit extreme unless every microamp matters.
Also wouldnt disabling the various clocks effectively shutdown SPI i2c and uart? IE this code...

Code: Select all

void DeeperSleep (uint32_t timeMS)
{
  //turning off as many clocks as possible before going to deep sleep. Needs reenabling when woken.
  //Should help reduce sleep power consumption to the uA
  __HAL_RCC_USART1_CLK_DISABLE();
  __HAL_RCC_USART2_CLK_DISABLE();
  __HAL_RCC_USART3_CLK_DISABLE();
  __HAL_RCC_USART4_CLK_DISABLE();
  __HAL_RCC_USART5_CLK_DISABLE();
  __HAL_RCC_USART6_CLK_DISABLE();

  __HAL_RCC_SPI1_CLK_DISABLE();
  __HAL_RCC_SPI2_CLK_DISABLE();

  __HAL_RCC_I2C1_CLK_DISABLE();
  __HAL_RCC_I2C2_CLK_DISABLE();

  __HAL_RCC_ADC1_CLK_DISABLE();

  __HAL_RCC_TIM1_CLK_DISABLE();
  __HAL_RCC_TIM3_CLK_DISABLE();
  __HAL_RCC_TIM6_CLK_DISABLE();
  __HAL_RCC_TIM7_CLK_DISABLE();
  __HAL_RCC_TIM14_CLK_DISABLE();
  __HAL_RCC_TIM15_CLK_DISABLE();
  __HAL_RCC_TIM16_CLK_DISABLE();
  __HAL_RCC_TIM17_CLK_DISABLE();

  __HAL_RCC_GPIOA_CLK_DISABLE();
  __HAL_RCC_GPIOB_CLK_DISABLE(); // might still be able to wake on EXT1 if switched off.
  __HAL_RCC_GPIOC_CLK_DISABLE();
  __HAL_RCC_GPIOD_CLK_DISABLE();

  __HAL_RCC_CRC_CLK_DISABLE();

  __HAL_RCC_DMA1_CLK_DISABLE();

  // Enter low-power sleep mode using LowPower library
  LowPower.deepSleep (timeMS);

}
yes disabling the various clocks effectively *switch off* the entire subsystem, and you would need to setup clocks again and re-initialise every peripheral on resume / wakeup. It is practically *switch off* the whole system. This would help if your intended 'deep sleep' is practically *switch off* and a toggle e.g. 'switch on' is good as a full power cycle and initialize everything from scratch.

I'd use this if I intended to do 'soft' power off, i.e. press a toggle tactile button to power off, and toggle again to power on.
But that this can be useful in automation scenarios if that 'toggle on' has enough time for you to bootstrap from completely off to on and perhaps handle the event.

I'd guess a short cut to doing this is when waking up from deep sleep is to do a NVIC_System_reset() and practically 'reboot'

There is one thing you can use to keep state across resets, they are the backup registers, sram is cleared but that backup registers keep values.
some stm32 socs has backup memory which can store even more data.

my own habit with power is that if possible keep it running connected to power e.g. a usb phone charger.
if not use a large battery e.g. a usb power bank or lipo batteries
and to 'save power', I tend to place

Code: Select all

asm("wfi"); //wait for systick
at the bottom of loop(), that makes loop() run every millisecond and I've observed that the cpu/soc runs at a lower temperature, thus saving power, by simply doing this.

I tend to think 'deep sleep' etc is 'too much hassle' as one'd need to think about 'keeping state between standby/resets', it is easier to cause bugs that way.
Yeah every uA counts, were doing a low powered system thats meant to wake periodically, with it being able to last several weeks if not months off a couple of 18650 backup batteries. There might be other parasitic currents going on. Like you say pullup or pulldown resistors. But need to shave as much off as possible.

Theres also shutdown, it might be possible to come up with a program that like you say, shuts off and some how saves some regs... or maybe simple do a smaller boot up sequence or some how skip steps. Thats going to need some real thinking.
Just a dogs body developer, mostly making props and stuff...
Post Reply

Return to “General discussion”