Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
cubexHal.pdf
Скачиваний:
110
Добавлен:
10.02.2016
Размер:
16.16 Mб
Скачать

UM1725

HAL PWR Generic Driver

42 HAL PWR Generic Driver

42.1PWR Firmware driver registers structures

42.1.1PWR_PVDTypeDef

Data Fields

uint32_t PVDLevel

uint32_t Mode

Field Documentation

uint32_t PWR_PVDTypeDef::PVDLevel

PVDLevel: Specifies the PVD detection level. This parameter can be a value of

PWR_PVD_detection_level

uint32_t PWR_PVDTypeDef::Mode

Mode: Specifies the operating mode for the selected pins. This parameter can be a value of PWR_PVD_Mode

42.2PWR Firmware driver API description

42.2.1Initialization and de-initialization functions

After reset, the backup domain (RTC registers, RTC backup data registers and backup SRAM) is protected against possible unwanted write accesses. To enable access to the RTC Domain and RTC registers, proceed as follows:

Enable the Power Controller (PWR) APB1 interface clock using the __HAL_RCC_PWR_CLK_ENABLE() macro.

Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.

This section contains the following APIs:

HAL_PWR_DeInit()

HAL_PWR_EnableBkUpAccess()

HAL_PWR_DisableBkUpAccess()

42.2.2Peripheral 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.

DOCID025834 Rev 2

513/900

HAL PWR Generic Driver

UM1725

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. Only for STM32F446xx there are two Wake-Up pins: Pin1 on PA.00 and Pin 2 on PC.13

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(PWR_MAINREGULATOR_ON,

PWR_SLEEPENTRY_WFI) functions with

PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction

PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction 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(PWR_MAINREGULATOR_ON) function with:

Main regulator ON.

Low Power regulator ON.

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:

514/900

DOCID025834 Rev 2

UM1725

HAL PWR Generic Driver

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.

This section contains the following APIs:

HAL_PWR_ConfigPVD()

HAL_PWR_EnablePVD()

HAL_PWR_DisablePVD()

HAL_PWR_EnableWakeUpPin()

HAL_PWR_DisableWakeUpPin()

HAL_PWR_EnterSLEEPMode()

HAL_PWR_EnterSTOPMode()

HAL_PWR_EnterSTANDBYMode()

HAL_PWR_PVD_IRQHandler()

HAL_PWR_PVDCallback()

HAL_PWR_EnableSleepOnExit()

HAL_PWR_DisableSleepOnExit()

HAL_PWR_EnableSEVOnPend()

HAL_PWR_DisableSEVOnPend()

42.2.3HAL_PWR_DeInit

Function Name

void HAL_PWR_DeInit (void )

Function Description

Deinitializes the HAL PWR peripheral registers to their default

 

reset values.

Return values

None

42.2.4HAL_PWR_EnableBkUpAccess

Function Name

void HAL_PWR_EnableBkUpAccess (void )

 

Function Description

Enables access to the backup domain (RTC registers, RTC

 

backup data registers and backup SRAM).

 

Return values

None

 

 

DOCID025834 Rev 2

515/900

HAL PWR Generic Driver

UM1725

Notes

If the HSE divided by 2, 3, ..31 is used as the RTC clock, the

 

Backup Domain Access should be kept enabled.

42.2.5HAL_PWR_DisableBkUpAccess

Function Name

void HAL_PWR_DisableBkUpAccess (void )

Function Description

Disables access to the backup domain (RTC registers, RTC

 

backup data registers and backup SRAM).

Return values

None

Notes

If the HSE divided by 2, 3, ..31 is used as the RTC clock, the

 

Backup Domain Access should be kept enabled.

42.2.6HAL_PWR_ConfigPVD

Function Name

void HAL_PWR_ConfigPVD (PWR_PVDTypeDef * sConfigPVD)

Function Description

Configures the voltage threshold detected by the Power Voltage

 

Detector(PVD).

Parameters

 

sConfigPVD: pointer to an PWR_PVDTypeDef structure that

 

 

contains the configuration information for the PVD.

Return values

 

None

Notes

Refer to the electrical characteristics of your device datasheet

 

 

for more details about the voltage threshold corresponding to

 

 

each detection level.

42.2.7HAL_PWR_EnablePVD

Function Name

void HAL_PWR_EnablePVD (void )

Function Description

Enables the Power Voltage Detector(PVD).

Return values

None

42.2.8HAL_PWR_DisablePVD

Function Name

void HAL_PWR_DisablePVD (void )

Function Description

Disables the Power Voltage Detector(PVD).

Return values

None

42.2.9HAL_PWR_EnableWakeUpPin

Function Name

void HAL_PWR_EnableWakeUpPin (uint32_t WakeUpPinx)

Function Description

Enables the Wake-up PINx functionality.

Parameters

 

WakeUpPinx: Specifies the Power Wake-Up pin to enable.

 

 

This parameter can be one of the following values:

 

 

PWR_WAKEUP_PIN1PWR_WAKEUP_PIN2 only available in

 

 

case of STM32F446xx devices

Return values

 

None

42.2.10HAL_PWR_DisableWakeUpPin

516/900

DOCID025834 Rev 2

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]