I try to configure my STM32 to obtain the lowest power consumption. For that I'm using deepsleep() function from mbed librairies. Before that I disable GPIO with this function

void SystemPower_Config(void)
  /* Enable Power Control clock */

  /* Enable Ultra low power mode */

  /* Enable the fast wake up from Ultra low power mode */

  GPIO_InitTypeDef GPIO_InitStructure = {0};
  GPIO_InitStructure.Pin = GPIO_PIN_All;
  GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStructure.Pull = GPIO_NOPULL;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);
  HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);

My main look like that

int main()
To generate interuption I use RTC alarms to leave the deepSleep mode. This part work fine but the problem is, the first time(during the first deepSleep) my consumption is equals to 1uA. After that my consumption is around 2.5uA on each deepSleep. So I think the deepSleep function change something the first time in the registrers or something like that. Have you any idea ?

Thank you very much for your help angain.


  • \$\begingroup\$ Isn't the implementation of the STM32 libraries open source? The easiest is probably to have a look at the deepSleep code, the answer should be there. If you find it, be sure to answer your own question here. \$\endgroup\$ – dim Dec 19 '16 at 16:33
  • \$\begingroup\$ I allready try to find something in the HAL_PWR_EnterSTOPMode function. But I did not see anything. \$\endgroup\$ – Simon NOWAK Dec 20 '16 at 8:37
  • \$\begingroup\$ You should post your answer as an answer... \$\endgroup\$ – Sean Houlihane Dec 23 '16 at 0:16

I finally find the solution. Instead of using the function deepsleep I use HAL_PWR_EnterSTOPMode() function with the clear wake up flag. Like that

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.