STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
Peripheral Control functions

Low Power modes configuration functions. More...

Collaboration diagram for Peripheral Control functions:

Functions

void HAL_PWR_ConfigPVD (PWR_PVDTypeDef *sConfigPVD)
 Configures the voltage threshold detected by the Power Voltage Detector(PVD).
 
void HAL_PWR_EnablePVD (void)
 Enables the Power Voltage Detector(PVD).
 
void HAL_PWR_DisablePVD (void)
 Disables the Power Voltage Detector(PVD).
 
void HAL_PWR_EnableWakeUpPin (uint32_t WakeUpPinx)
 Enables the Wake-up PINx functionality.
 
void HAL_PWR_DisableWakeUpPin (uint32_t WakeUpPinx)
 Disables the Wake-up PINx functionality.
 
void HAL_PWR_EnterSTOPMode (uint32_t Regulator, uint8_t STOPEntry)
 Enters Stop mode.
 
void HAL_PWR_EnterSLEEPMode (uint32_t Regulator, uint8_t SLEEPEntry)
 Enters Sleep mode.
 
void HAL_PWR_EnterSTANDBYMode (void)
 Enters Standby mode.
 
void HAL_PWR_PVD_IRQHandler (void)
 This function handles the PWR PVD interrupt request.
 
void HAL_PWR_PVDCallback (void)
 PWR PVD interrupt callback.
 
void HAL_PWR_EnableSleepOnExit (void)
 Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.
 
void HAL_PWR_DisableSleepOnExit (void)
 Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.
 
void HAL_PWR_EnableSEVOnPend (void)
 Enables CORTEX M4 SEVONPEND bit.
 
void HAL_PWR_DisableSEVOnPend (void)
 Disables CORTEX M4 SEVONPEND bit.
 

Detailed Description

Low Power modes configuration functions.

 ===============================================================================
                 ##### Peripheral Control functions #####
 ===============================================================================
     
    *** PVD configuration ***
    =========================
    [..]
      (+) The PVD is used to monitor the VDD power supply by comparing it to a 
          threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
      (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower 
          than the PVD threshold. This event is internally connected to the EXTI 
          line16 and can generate an interrupt if enabled. This is done through
          __HAL_PWR_PVD_EXTI_ENABLE_IT() macro.
      (+) The PVD is stopped in Standby mode.

    *** Wake-up pin configuration ***
    ================================
    [..]
      (+) Wake-up pin is used to wake up the system from Standby mode. This pin is 
          forced in input pull-down configuration and is active on rising edges.
      (+) There is one Wake-up pin: Wake-up Pin 1 on PA.00.
       (++) For STM32F446xx there are two Wake-Up pins: Pin1 on PA.00 and Pin2 on PC.13
           (++) For STM32F410xx/STM32F412xx/STM32F413xx/STM32F423xx  there are three Wake-Up pins: Pin1 on PA.00, Pin2 on PC.00 and Pin3 on PC.01 

    *** Low Power modes configuration ***
    =====================================
    [..]
      The devices feature 3 low-power modes:
      (+) Sleep mode: Cortex-M4 core stopped, peripherals kept running.
      (+) Stop mode: all clocks are stopped, regulator running, regulator 
          in low power mode
      (+) Standby mode: 1.2V domain powered off.
   
   *** Sleep mode ***
   ==================
    [..]
      (+) Entry:
        The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(Regulator, SLEEPEntry)
              functions with
          (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
          (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
          (++) PWR_SLEEPENTRY_WFE_NO_EVT_CLEAR: Enter SLEEP mode with WFE instruction and
                                                no clear of pending event before.
      
      -@@- The Regulator parameter is not used for the STM32F4 family 
              and is kept as parameter just to maintain compatibility with the 
              lower power families (STM32L).
      (+) Exit:
        Any peripheral interrupt acknowledged by the nested vectored interrupt 
              controller (NVIC) can wake up the device from Sleep mode.

   *** Stop mode ***
   =================
    [..]
      In Stop mode, all clocks in the 1.2V domain are stopped, the PLL, the HSI,
      and the HSE RC oscillators are disabled. Internal SRAM and register contents 
      are preserved.
      The voltage regulator can be configured either in normal or low-power mode.
      To minimize the consumption In Stop mode, FLASH can be powered off before 
      entering the Stop mode using the HAL_PWREx_EnableFlashPowerDown() function.
      It can be switched on again by software after exiting the Stop mode using
      the HAL_PWREx_DisableFlashPowerDown() function. 

      (+) Entry:
         The Stop mode is entered using the HAL_PWR_EnterSTOPMode(Regulator, STOPEntry) 
             function with:
       (++) Regulator:
        (+++) Main regulator ON.
        (+++) Low Power regulator ON.
       (++) STOPEntry:
        (+++) PWR_STOPENTRY_WFI              : Enter STOP mode with WFI instruction.
        (+++) PWR_STOPENTRY_WFE              : Enter STOP mode with WFE instruction and
                                               clear of pending events before.
        (+++) PWR_STOPENTRY_WFE_NO_EVT_CLEAR : Enter STOP mode with WFE instruction and
                                               no clear of pending event before.
      (+) Exit:
        Any EXTI Line (Internal or External) configured in Interrupt/Event mode.

   *** Standby mode ***
   ====================
    [..]
    (+)
      The Standby mode allows to achieve the lowest power consumption. It is based 
      on the Cortex-M4 deep sleep mode, with the voltage regulator disabled. 
      The 1.2V domain is consequently powered off. The PLL, the HSI oscillator and 
      the HSE oscillator are also switched off. SRAM and register contents are lost 
      except for the RTC registers, RTC backup registers, backup SRAM and Standby 
      circuitry.
   
      The voltage regulator is OFF.
      
      (++) Entry:
        (+++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
      (++) Exit:
        (+++) WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wake-up,
             tamper event, time-stamp event, external reset in NRST pin, IWDG reset.

   *** Auto-wake-up (AWU) from low-power mode ***
   =============================================
    [..]
    
     (+) The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC 
      Wake-up event, a tamper event or a time-stamp event, without depending on 
      an external interrupt (Auto-wake-up mode).

      (+) RTC auto-wake-up (AWU) from the Stop and Standby modes
       
        (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to 
              configure the RTC to generate the RTC alarm using the HAL_RTC_SetAlarm_IT() function.

        (++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it 
             is necessary to configure the RTC to detect the tamper or time stamp event using the
                HAL_RTCEx_SetTimeStamp_IT() or HAL_RTCEx_SetTamper_IT() functions.
                  
        (++) To wake up from the Stop mode with an RTC Wake-up event, it is necessary to
              configure the RTC to generate the RTC Wake-up event using the HAL_RTCEx_SetWakeUpTimer_IT() function.

Function Documentation

◆ HAL_PWR_ConfigPVD()

void HAL_PWR_ConfigPVD ( PWR_PVDTypeDef * sConfigPVD)

#include <stm32f4xx_hal_pwr.h>

Configures the voltage threshold detected by the Power Voltage Detector(PVD).

Parameters
sConfigPVDpointer to an PWR_PVDTypeDef structure that contains the configuration information for the PVD.
Note
Refer to the electrical characteristics of your device datasheet for more details about the voltage threshold corresponding to each detection level.
Return values
None

Definition at line 275 of file stm32f4xx_hal_pwr.c.

References __HAL_PWR_PVD_EXTI_DISABLE_EVENT, __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE, __HAL_PWR_PVD_EXTI_DISABLE_IT, __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE, __HAL_PWR_PVD_EXTI_ENABLE_EVENT, __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE, __HAL_PWR_PVD_EXTI_ENABLE_IT, __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE, assert_param, IS_PWR_PVD_LEVEL, IS_PWR_PVD_MODE, PWR_PVDTypeDef::Mode, PVD_FALLING_EDGE, PVD_MODE_EVT, PVD_MODE_IT, PVD_RISING_EDGE, and PWR_PVDTypeDef::PVDLevel.

◆ HAL_PWR_EnablePVD()

void HAL_PWR_EnablePVD ( void )

#include <stm32f4xx_hal_pwr.h>

Enables the Power Voltage Detector(PVD).

Return values
None

Definition at line 318 of file stm32f4xx_hal_pwr.c.

References CR_PVDE_BB.

◆ HAL_PWR_DisablePVD()

void HAL_PWR_DisablePVD ( void )

#include <stm32f4xx_hal_pwr.h>

Disables the Power Voltage Detector(PVD).

Return values
None

Definition at line 327 of file stm32f4xx_hal_pwr.c.

References CR_PVDE_BB.

◆ HAL_PWR_EnableWakeUpPin()

void HAL_PWR_EnableWakeUpPin ( uint32_t WakeUpPinx)

#include <stm32f4xx_hal_pwr.h>

Enables the Wake-up PINx functionality.

Parameters
WakeUpPinxSpecifies the Power Wake-Up pin to enable. This parameter can be one of the following values:
  • PWR_WAKEUP_PIN1
  • PWR_WAKEUP_PIN2 available only on STM32F410xx/STM32F446xx/STM32F412xx/STM32F413xx/STM32F423xx devices
  • PWR_WAKEUP_PIN3 available only on STM32F410xx/STM32F412xx/STM32F413xx/STM32F423xx devices
Return values
None

Definition at line 341 of file stm32f4xx_hal_pwr.c.

References assert_param, and IS_PWR_WAKEUP_PIN.

◆ HAL_PWR_DisableWakeUpPin()

void HAL_PWR_DisableWakeUpPin ( uint32_t WakeUpPinx)

#include <stm32f4xx_hal_pwr.h>

Disables the Wake-up PINx functionality.

Parameters
WakeUpPinxSpecifies the Power Wake-Up pin to disable. This parameter can be one of the following values:
  • PWR_WAKEUP_PIN1
  • PWR_WAKEUP_PIN2 available only on STM32F410xx/STM32F446xx/STM32F412xx/STM32F413xx/STM32F423xx devices
  • PWR_WAKEUP_PIN3 available only on STM32F410xx/STM32F412xx/STM32F413xx/STM32F423xx devices
Return values
None

Definition at line 359 of file stm32f4xx_hal_pwr.c.

References assert_param, and IS_PWR_WAKEUP_PIN.

◆ HAL_PWR_EnterSTOPMode()

void HAL_PWR_EnterSTOPMode ( uint32_t Regulator,
uint8_t STOPEntry )

#include <stm32f4xx_hal_pwr.h>

Enters Stop mode.

Note
In Stop mode, all I/O pins keep the same state as in Run mode.
When exiting Stop mode by issuing an interrupt or a wake-up event, the HSI RC oscillator is selected as system clock.
When the voltage regulator operates in low power mode, an additional startup delay is incurred when waking up from Stop mode. By keeping the internal regulator ON during Stop mode, the consumption is higher although the startup time is reduced.
Parameters
RegulatorSpecifies the regulator state in Stop mode. This parameter can be one of the following values:
  • PWR_MAINREGULATOR_ON: Stop mode with regulator ON
  • PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
STOPEntrySpecifies if Stop mode in entered with WFI or WFE instruction. This parameter can be one of the following values:
  • PWR_STOPENTRY_WFI : Enter Stop mode with WFI instruction
  • PWR_STOPENTRY_WFE : Enter Stop mode with WFE instruction and clear of pending events before.
  • PWR_STOPENTRY_WFE_NO_EVT_CLEAR : Enter STOP mode with WFE instruction and no clear of pending event before.
Return values
None

Definition at line 445 of file stm32f4xx_hal_pwr.c.

References assert_param, IS_PWR_REGULATOR, IS_PWR_STOP_ENTRY, PWR_STOPENTRY_WFE_NO_EVT_CLEAR, and PWR_STOPENTRY_WFI.

◆ HAL_PWR_EnterSLEEPMode()

void HAL_PWR_EnterSLEEPMode ( uint32_t Regulator,
uint8_t SLEEPEntry )

#include <stm32f4xx_hal_pwr.h>

Enters Sleep mode.

Note
In Sleep mode, all I/O pins keep the same state as in Run mode.
In Sleep mode, the systick is stopped to avoid exit from this mode with systick interrupt when used as time base for Timeout
Parameters
RegulatorSpecifies the regulator state in SLEEP mode. This parameter can be one of the following values:
  • PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
  • PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
Note
This parameter is not used for the STM32F4 family and is kept as parameter just to maintain compatibility with the lower power families.
Parameters
SLEEPEntrySpecifies if SLEEP mode in entered with WFI or WFE instruction. This parameter can be one of the following values:
  • PWR_SLEEPENTRY_WFI : Enter SLEEP mode with WFI instruction
  • PWR_SLEEPENTRY_WFE : Enter SLEEP mode with WFE instruction and clear of pending events before.
  • PWR_SLEEPENTRY_WFE_NO_EVT_CLEAR : Enter SLEEP mode with WFE instruction and no clear of pending event before.
Return values
None

Definition at line 391 of file stm32f4xx_hal_pwr.c.

References assert_param, IS_PWR_REGULATOR, IS_PWR_SLEEP_ENTRY, PWR_SLEEPENTRY_WFE_NO_EVT_CLEAR, PWR_SLEEPENTRY_WFI, and UNUSED.

◆ HAL_PWR_EnterSTANDBYMode()

void HAL_PWR_EnterSTANDBYMode ( void )

#include <stm32f4xx_hal_pwr.h>

Enters Standby mode.

Note
In Standby mode, all I/O pins are high impedance except for:
  • Reset pad (still available)
  • RTC_AF1 pin (PC13) if configured for tamper, time-stamp, RTC Alarm out, or RTC clock calibration out.
  • RTC_AF2 pin (PI8) if configured for tamper or time-stamp.
  • WKUP pin 1 (PA0) if enabled.
Return values
None

Definition at line 488 of file stm32f4xx_hal_pwr.c.

◆ HAL_PWR_PVD_IRQHandler()

void HAL_PWR_PVD_IRQHandler ( void )

#include <stm32f4xx_hal_pwr.h>

This function handles the PWR PVD interrupt request.

Note
This API should be called under the PVD_IRQHandler().
Return values
None

Definition at line 509 of file stm32f4xx_hal_pwr.c.

References __HAL_PWR_PVD_EXTI_CLEAR_FLAG, __HAL_PWR_PVD_EXTI_GET_FLAG, and HAL_PWR_PVDCallback().

◆ HAL_PWR_PVDCallback()

__weak void HAL_PWR_PVDCallback ( void )

#include <stm32f4xx_hal_pwr.h>

PWR PVD interrupt callback.

Return values
None

Definition at line 526 of file stm32f4xx_hal_pwr.c.

Referenced by HAL_PWR_PVD_IRQHandler().

◆ HAL_PWR_EnableSleepOnExit()

void HAL_PWR_EnableSleepOnExit ( void )

#include <stm32f4xx_hal_pwr.h>

Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.

Note
Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor re-enters SLEEP mode when an interruption handling is over. Setting this bit is useful when the processor is expected to run only on interruptions handling.
Return values
None

Definition at line 541 of file stm32f4xx_hal_pwr.c.

◆ HAL_PWR_DisableSleepOnExit()

void HAL_PWR_DisableSleepOnExit ( void )

#include <stm32f4xx_hal_pwr.h>

Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.

Note
Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor re-enters SLEEP mode when an interruption handling is over.
Return values
None

Definition at line 553 of file stm32f4xx_hal_pwr.c.

◆ HAL_PWR_EnableSEVOnPend()

void HAL_PWR_EnableSEVOnPend ( void )

#include <stm32f4xx_hal_pwr.h>

Enables CORTEX M4 SEVONPEND bit.

Note
Sets SEVONPEND bit of SCR register. When this bit is set, this causes WFE to wake up when an interrupt moves from inactive to pended.
Return values
None

Definition at line 565 of file stm32f4xx_hal_pwr.c.

◆ HAL_PWR_DisableSEVOnPend()

void HAL_PWR_DisableSEVOnPend ( void )

#include <stm32f4xx_hal_pwr.h>

Disables CORTEX M4 SEVONPEND bit.

Note
Clears SEVONPEND bit of SCR register. When this bit is set, this causes WFE to wake up when an interrupt moves from inactive to pended.
Return values
None

Definition at line 577 of file stm32f4xx_hal_pwr.c.