F401 blackpill no deepsleep

Post here first, or if you can't find a relevant section!
Post Reply
remis
Posts: 3
Joined: Fri Apr 05, 2024 9:38 am

F401 blackpill no deepsleep

Post by remis »

Hi
Blackpill stm32F401 deepsleep : 5mA !
I'm trying this simple example:

https://github.com/stm32duino/STM32LowP ... Wakeup.ino

with external 3v3 supply, I remove on board regulator , LED, I disconnect Tx RX line used for programming : no improvement

I see this, without solution
viewtopic.php?p=13479&hilit=blackpill#p13479
Is there somebody that use STM32 duino, F401 and deepsleep with succes?
thanks
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: F401 blackpill no deepsleep

Post by fpiSTM »

Hi,
deepsleep (stop mode) works as expected.
I've tested with a Nucleo F401RE, I've got something close to your value (3 mA when the LED is OFF).
Anyway, you probably have to ensure all unused pins are set to Analog Input and the respective GPIO port clock disabled.
The library can't do that for you as it cannot know which one is used or not.

Try to add this in the setup, as the LED is connected to PA5, only pin 5 for GPIOA is preserved and GPIOA clock not disabled.

Code: Select all

GPIO_InitTypeDef GPIO_InitStruct;
 
  /* Configure all GPIO as analog to reduce current consumption on non used IOs */
  /* Enable GPIOs clock */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOE_CLK_ENABLE();
  __HAL_RCC_GPIOH_CLK_ENABLE();
 
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Pin = GPIO_PIN_All;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  GPIO_InitStruct.Pin = GPIO_PIN_All ^ GPIO_PIN_5;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 
  /* Disable GPIOs clock */
  // __HAL_RCC_GPIOA_CLK_DISABLE();
  __HAL_RCC_GPIOB_CLK_DISABLE();
  __HAL_RCC_GPIOC_CLK_DISABLE();
  __HAL_RCC_GPIOD_CLK_DISABLE();
  __HAL_RCC_GPIOE_CLK_DISABLE();
  __HAL_RCC_GPIOH_CLK_DISABLE();
With this, it reach 11 µA.
Nucleo_F401RE_deepSleep.jpg
Nucleo_F401RE_deepSleep.jpg (84.61 KiB) Viewed 217 times
remis
Posts: 3
Joined: Fri Apr 05, 2024 9:38 am

Re: F401 blackpill no deepsleep

Post by remis »

Merci Frédéric pour cette réponse.

I simply add this code in setup : always 4mA in deep sleep.
Maybe the IDEarduino setup add some wrong configuration.
i will try with a Nucleo board.

Stm32duino lowpower and arduino IDE :

Code: Select all


#include "STM32LowPower.h"

void setup() {

GPIO_InitTypeDef GPIO_InitStruct;
  /* Configure all GPIO as analog to reduce current consumption on non used IOs */
  /* Enable GPIOs clock */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();
  __HAL_RCC_GPIOE_CLK_ENABLE();
  __HAL_RCC_GPIOH_CLK_ENABLE();

  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Pin = GPIO_PIN_All;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  GPIO_InitStruct.Pin = GPIO_PIN_All ^ GPIO_PIN_5; // with or without : same current 

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /* Disable GPIOs clock */
  // __HAL_RCC_GPIOA_CLK_DISABLE();
  __HAL_RCC_GPIOB_CLK_DISABLE();
  __HAL_RCC_GPIOC_CLK_DISABLE();
  __HAL_RCC_GPIOD_CLK_DISABLE();
  __HAL_RCC_GPIOE_CLK_DISABLE();
  __HAL_RCC_GPIOH_CLK_DISABLE();

  pinMode(LED_BUILTIN, OUTPUT);
  // Configure low power
  LowPower.begin();
}

void loop() {
  // Configure low power
  LowPower.deepSleep(5000);
  digitalWrite(LED_BUILTIN, HIGH);
  LowPower.deepSleep(3000);
  digitalWrite(LED_BUILTIN, LOW);
  LowPower.deepSleep(3000);
}
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: F401 blackpill no deepsleep

Post by fpiSTM »

Note that the measure is done on IDD. So only the MCU consumption is measured.
remis
Posts: 3
Joined: Fri Apr 05, 2024 9:38 am

Re: F401 blackpill no deepsleep

Post by remis »

Hello
I don"t have exact black-pill schematic . I cut the 5v - 3v3 on board regulator : -3mA
I remove LED ( -0.5mA) : Idc=1mA now

I know that 0.3mA result from 10k pull up on boot switch.

next step will be on nucleo board with real schematic.

...
Post Reply

Return to “General discussion”