stm32duino / STM32LowPower

Arduino Low Power library for STM32
183 stars 52 forks source link

stm32L4+ going to STOP2 lowpower mode must keep SRAM3 #66

Closed FRASTM closed 2 years ago

FRASTM commented 2 years ago

On the stm32L4+ , the low power DEEP_SLEEP mode corresponds to STOP2 low power mode. In this case, the SRAM3 must be powered during the low power phase since it is a part of the SRAM area for this target (SRAM is made of SRAM1+SRAM2+SRAM3). By default, the content of the SRAM3 is lost during STOP2 low power mode and consequently this must be changed.

Fixes #64

Signed-off-by: Francois Ramu francois.ramu@st.com

FRASTM commented 2 years ago

Going to STOP2 (stm32duino deepsleep mode) with SRAM3 powered is similar (in terms of current consumption and wakeup time) to STOP1 mode.

@@ -295,8 +295,8 @@ void LowPower_stop(serial_t *obj)
       || (WakeUpUart->Instance == (USART_TypeDef *)LPUART2_BASE)
 #endif
      ) {
-    // STM32L4xx supports STOP2 mode which halves consumption
-    HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
+    // STM32L4xx supports STOP1 mode which halves consumption and maintains SRAM3
+    HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
   } else
 #endif
   {