Question
STM32L1 Stop mode usage
Hello, I have problem with entering to the stop mode again
Here is my function to configure stop mode, used once before main loop, and it's ok after that MCU goes to stop mode and power consumption is low.
void EnterLowPowerMode(void) { //used just once
GPIO_InitTypeDef GPIO_InitStruct = {0};
/*Configure GPIO pin : Backlight_Pin */
GPIO_InitStruct.Pin = Backlight_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(Backlight_GPIO_Port, &GPIO_InitStruct);
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
HAL_TIM_Base_Stop_IT(&htim3);
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0xFFFF, RTC_WAKEUPCLOCK_RTCCLK_DIV16); //30s RTC timer
__HAL_RCC_PWR_CLK_ENABLE(); // Enable Power Control clock
HAL_PWREx_EnableUltraLowPower(); // Ultra low power mode
HAL_PWREx_EnableFastWakeUp(); // Fast wake-up for ultra low power mode
HAL_PWR_EnableSleepOnExit(); /* Re-enters SLEEP mode when an interruption handling is over */
HAL_SuspendTick(); /* To Avoid timer wake-up. */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);
/* We are now waiting for TAMPERF1 or WAKEUP interrupts (or Reset) */
}Using interrupt I quit from stop mode and it's ok MCU goes to run mode
HAL_PWR_DisableSleepOnExit();
SystemClock_Config();
HAL_ResumeTick();After that I want again enter to stop mode, if I call EnterLowPowerMode(), MCU freeze.
If I use
HAL_PWR_EnableSleepOnExit();MCU uses too much power as if it were not in stop mode (300uA)
