Page 1 of 1
F401 blackpill no deepsleep
Posted: Fri Apr 05, 2024 10:43 am
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
Re: F401 blackpill no deepsleep
Posted: Fri Apr 05, 2024 1:19 pm
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 (84.61 KiB) Viewed 4444 times
Re: F401 blackpill no deepsleep
Posted: Mon Apr 15, 2024 9:08 am
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);
}
Re: F401 blackpill no deepsleep
Posted: Mon Apr 15, 2024 9:56 am
by fpiSTM
Note that the measure is done on IDD. So only the MCU consumption is measured.
Re: F401 blackpill no deepsleep
Posted: Mon Apr 15, 2024 11:46 am
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.
...
Re: F401 blackpill no deepsleep
Posted: Fri May 03, 2024 3:15 pm
by remis
hello
accurate measurement today with nucleo 64 F401 Re
Idc measurement on IDD jumper
with simple deep sleep call : 250µA
with port disable : 40µA.
Thus , black pill is low cost but not able to work in deep sleep mode : Schematic is not accurate.
It's better to build your own circuit or buy a nucleo 64...401 re
https://www.st.com/resource/en/data_bri ... c031c6.pdf