6. Power control (PWR)

6.1 Power supplies

The STM32F334xx devices require a 2.0 V - 3.6 V operating supply voltage ( \( V_{DD} \) ) and a 2.0 V - 3.6 V analog supply voltage ( \( V_{DDA} \) ). The embedded regulator is used to supply the internal 1.8 V digital power.

The real-time clock (RTC) and backup registers can be powered from the \( V_{BAT} \) voltage when the main \( V_{DD} \) supply is powered off.

Figure 6. Power supply overview

Figure 6. Power supply overview diagram showing the internal power domains and their connections to external pins.

The diagram illustrates the power supply architecture of the STM32F334xx device, showing three main power domains and their connections to external pins:

External pins shown on the left are \( V_{SSA} \) , \( V_{DDA} \) , \( V_{SS} \) , \( V_{DD} \) , and \( V_{BAT} \) . A switch indicates that the RTC domain can be powered from \( V_{BAT} \) when \( V_{DD} \) is off. The code MS19668V2 is shown in the bottom right corner.

Figure 6. Power supply overview diagram showing the internal power domains and their connections to external pins.

The following supply voltages are available:

6.1.1 Independent A/D and D/A converter supply and reference voltage

To improve conversion accuracy, the ADC and the DAC have an independent power supply which can be separately filtered and shielded from noise on the PCB.

The ADC and DAC voltage supply input is available on a separate \( V_{DDA} \) pin. An isolated supply ground connection is provided on the \( V_{SSA} \) pin.

64-pin, 48-pin and 32-pin package connections

On these packages, the \( V_{REF+} \) and \( V_{REF-} \) pins are not available. They are internally connected to the ADC voltage supply ( \( V_{DDA} \) ) and ground ( \( V_{SSA} \) ) respectively.

The \( V_{DDA} \) supply/reference voltage can be equal to or higher than \( V_{DD} \) . When a single supply is used, \( V_{DDA} \) can be externally connected to \( V_{DD} \) , through the external filtering circuit in order to ensure a noise free \( V_{DDA} \) /reference voltage.

When \( V_{DDA} \) is different from \( V_{DD} \) , \( V_{DDA} \) must always be higher or equal to \( V_{DD} \) . To maintain a safe potential difference between \( V_{DDA} \) and \( V_{DD} \) during power-up/power-down, an external Schottky diode can be used between \( V_{DD} \) and \( V_{DDA} \) . Refer to the datasheet for the maximum allowed difference.

6.1.2 Battery Backup domain

To retain the content of the backup registers and supply the RTC function when \( V_{DD} \) is turned off, \( V_{BAT} \) pin can be connected to an optional standby voltage supplied by a battery or by another source.

The \( V_{BAT} \) pin powers the RTC unit, the LSE oscillator and the PC13 to PC15 I/Os, allowing the RTC to operate even when the main power supply is turned off. The switch to the \( V_{BAT} \) supply is controlled by the power-down reset (PDR) embedded in the reset block.


Warning: During \( t_{RSTEMPO} \) (temporization at \( V_{DD} \) startup) or after a PDR is detected, the power switch between \( V_{BAT} \) and \( V_{DD} \) remains connected to \( V_{BAT} \) .
During the startup phase, if \( V_{DD} \) is established in less than \( t_{RSTEMPO} \) (Refer to the datasheet for the value of \( t_{RSTEMPO} \) ) and \( V_{DD} > V_{BAT} + 0.6 \) V, a current may be injected into \( V_{BAT} \) through an internal diode connected between \( V_{DD} \) and the power switch ( \( V_{BAT} \) ).
If the power supply/battery connected to the \( V_{BAT} \) pin cannot support this current injection, it is strongly recommended to

connect an external low-drop diode between this power supply and the \( V_{BAT} \) pin.


If no external battery is used in the application, it is recommended to connect \( V_{BAT} \) externally to \( V_{DD} \) with a 100 nF external ceramic decoupling capacitor (for more details refer to AN4206).

When the RTC domain is supplied by \( V_{DD} \) (analog switch connected to \( V_{DD} \) ), the following functions are available:

Note: Due to the fact that the switch only sinks a limited amount of current (3 mA), the use of GPIOs PC13 to PC15 in output mode is restricted: the speed has to be limited to 2 MHz with a maximum load of 30 pF and these I/Os must not be used as a current source (e.g. to drive an LED).

When the RTC domain is supplied by \( V_{BAT} \) (analog switch connected to \( V_{BAT} \) because \( V_{DD} \) is not present), the following functions are available:

6.1.3 Voltage regulator

The voltage regulator is always enabled after Reset. It works in three different modes depending on the application modes.

6.2 Power supply supervisor

6.2.1 Power on reset (POR)/power down reset (PDR)

The device has an integrated power-on reset (POR) and power-down reset (PDR) circuits which are always active and ensure proper operation above a threshold of 2 V.

The device remains in Reset mode when the monitored supply voltage is below a specified threshold, \( V_{POR/PDR} \) , without the need for an external reset circuit.

For more details on the power on /power down reset threshold, refer to the electrical characteristics section in the datasheet.

Figure 7. Power on reset/power down reset waveform

Figure 7. Power on reset/power down reset waveform. The graph shows the VDD/VDDA voltage level over time. The voltage rises from a low level to a high level, crossing a POR (Power On Reset) threshold. The voltage then falls, crossing a PDR (Power Down Reset) threshold. The hysteresis between the POR and PDR thresholds is 40 mV. The time interval between the POR and PDR thresholds is labeled as Temporization tRSTTEMPO. The Reset signal is shown as a horizontal line that goes high when the voltage crosses the POR threshold and goes low when it crosses the PDR threshold. The diagram is labeled MS19669V1.

The figure illustrates the power on reset (POR) and power down reset (PDR) waveform. The top graph shows the \( V_{DD}/V_{DDA} \) voltage level over time. The voltage rises from a low level to a high level, crossing a POR threshold. The voltage then falls, crossing a PDR threshold. The hysteresis between the POR and PDR thresholds is 40 mV. The time interval between the POR and PDR thresholds is labeled as Temporization \( t_{RSTTEMPO} \) . The bottom graph shows the Reset signal, which is a horizontal line that goes high when the voltage crosses the POR threshold and goes low when it crosses the PDR threshold. The diagram is labeled MS19669V1.

Figure 7. Power on reset/power down reset waveform. The graph shows the VDD/VDDA voltage level over time. The voltage rises from a low level to a high level, crossing a POR (Power On Reset) threshold. The voltage then falls, crossing a PDR (Power Down Reset) threshold. The hysteresis between the POR and PDR thresholds is 40 mV. The time interval between the POR and PDR thresholds is labeled as Temporization tRSTTEMPO. The Reset signal is shown as a horizontal line that goes high when the voltage crosses the POR threshold and goes low when it crosses the PDR threshold. The diagram is labeled MS19669V1.

6.2.2 Programmable voltage detector (PVD)

User can use the PVD to monitor the \( V_{DD} \) power supply by comparing it to a threshold selected by the PLS[2:0] bits in the Power control register (PWR_CR) .

The PVD is enabled by setting the PVDE bit.

A PVDO flag is available, in the Power control/status register (PWR_CSR) , to indicate if \( V_{DD} \) is higher or lower than the PVD threshold. This event is internally connected to the EXTI line 16 and can generate an interrupt if enabled through the EXTI registers. The rising/falling edge sensitivity of the EXTI Line 16 should be configured according to PVD output behavior i.e. if the EXTI line 16 is configured to rising edge sensitivity, the interrupt is generated when \( V_{DD} \) drops below the PVD threshold. As an example the service routine could perform emergency shutdown tasks.

Figure 8. PVD thresholds

Timing diagram showing VDD voltage and PVD output over time. The VDD line shows a ramp-up and ramp-down. The PVD output is a rectangular pulse that goes low when VDD drops below a threshold and returns high when VDD rises above a threshold. A 100 mV hysteresis is indicated between the two threshold levels.

The diagram illustrates the relationship between the supply voltage (V DD ) and the Power Voltage Detector (PVD) output. The top part shows V DD rising from a low value to a maximum and then falling. The PVD output, shown at the bottom, is initially high. As V DD falls, the PVD output goes low when V DD reaches a lower threshold. When V DD rises again, the PVD output returns to high when V DD reaches an upper threshold. The difference between these two thresholds is labeled as '100 mV hysteresis'. The thresholds are marked on the V DD ramp with horizontal dashed lines.

Timing diagram showing VDD voltage and PVD output over time. The VDD line shows a ramp-up and ramp-down. The PVD output is a rectangular pulse that goes low when VDD drops below a threshold and returns high when VDD rises above a threshold. A 100 mV hysteresis is indicated between the two threshold levels.

6.3 Low-power modes

By default, the microcontroller is in Run mode after a system or a power Reset. Several low-power modes are available to save power when the CPU does not need to be kept running, for example when waiting for an external event. It is up to the user to select the mode that gives the best compromise between low-power consumption, short startup time and available wakeup sources.

The device features three low-power modes:

In addition, the power consumption in Run mode can be reduced by one of the following means:

Table 14. Low-power mode summary

Mode nameEntrywakeupEffect on 1.8V domain clocksEffect on V DD domain clocksVoltage regulator
Sleep
(Sleep now or Sleep-on - exit)
WFIAny interruptCPU clock OFF
no effect on other clocks or analog clock sources
NoneON
WFEWakeup event

Table 14. Low-power mode summary

Mode nameEntrywakeupEffect on 1.8V domain clocksEffect on V DD domain clocksVoltage regulator
StopPDDS and LPDS bits + SLEEPDEEP bit + WFI or WFEAny EXTI line (configured in the EXTI registers)
Specific communication peripherals on reception events (USART, I2C)
All 1.8V domain clocks OFFHSI and HSE oscillators OFFON or in low-power mode (depends on Power control register (PWR_CR) )
StandbyPDDS bit + SLEEPDEEP bit + WFI or WFEWKUP pin rising edge, RTC alarm, external reset in NRST pin, IWDG resetOFF

6.3.1 Slowing down system clocks

In Run mode the speed of the system clocks (SYSCLK, HCLK, PCLK) can be reduced by programming the prescaler registers. These prescalers can also be used to slow down peripherals before entering Sleep mode.

For more details refer to Section 8.4.2: Clock configuration register (RCC_CFGR) .

6.3.2 Peripheral clock gating

In Run mode, the HCLK and PCLK for individual peripherals and memories can be stopped at any time to reduce power consumption.

To further reduce power consumption in Sleep mode the peripheral clocks can be disabled prior to executing the WFI or WFE instructions.

Peripheral clock gating is controlled by the AHB peripheral clock enable register (RCC_AHBENR), APB1 peripheral clock enable register (RCC_APB1ENR) and APB2 peripheral clock enable register (RCC_APB2ENR).

6.3.3 Sleep mode

Entering Sleep mode

The Sleep mode is entered by executing the WFI (Wait For Interrupt) or WFE (Wait for Event) instructions. Two options are available to select the Sleep mode entry mechanism, depending on the SLEEPONEXIT bit in the Arm ® Cortex ® -M4 System Control register:

In the Sleep mode, all I/O pins keep the same state as in the Run mode.

Refer to Table 15 and Table 16 for details on how to enter Sleep mode.

Exiting Sleep mode

If the WFI instruction is used to enter Sleep mode, any peripheral interrupt acknowledged by the nested vectored interrupt controller (NVIC) can wake up the device from Sleep mode.

If the WFE instruction is used to enter Sleep mode, the MCU exits Sleep mode as soon as an event occurs. The wakeup event can be generated either by:

This mode offers the lowest wakeup time as no time is wasted in interrupt entry/exit.

Refer to Table 15 and Table 16 for more details on how to exit Sleep mode.

Table 15. Sleep-now

Sleep-now modeDescription
Mode entryWFI (Wait for Interrupt) or WFE (Wait for Event) while:
– SLEEPDEEP = 0 and
– SLEEPONEXIT = 0
Refer to the Cortex-M4 System Control register.
Mode exitIf WFI was used for entry:
Interrupt: Refer to Table 35: STM32F334xx vector table
If WFE was used for entry
Wakeup event: Refer to Section 12.2.3: Wakeup event management
Wakeup latencyNone

Table 16. Sleep-on-exit

Sleep-on-exitDescription
Mode entryWFI (wait for interrupt) while:
– SLEEPDEEP = 0 and
– SLEEPONEXIT = 1
Refer to the Cortex-M4 System Control register.
Mode exitInterrupt: refer to Table 35: STM32F334xx vector table .
Wakeup latencyNone

6.3.4 Stop mode

The Stop mode is based on the Cortex-M4 deepsleep mode combined with peripheral clock gating. The voltage regulator can be configured either in normal or low-power mode in the STM32F334xx devices. In the Stop mode, all I/O pins keep the same state as in the Run mode.

Entering Stop mode

Refer to Table 17 for details on how to enter the Stop mode.

To further reduce power consumption in Stop mode, the internal voltage regulator can be put in low-power mode. This is configured by the LPDS bit of the Power control register (PWR_CR) .

If Flash memory programming is ongoing, the Stop mode entry is delayed until the memory access is finished.

If an access to the APB domain is ongoing, The Stop mode entry is delayed until the APB access is finished.

In Stop mode, the following features can be selected by programming individual control bits:

The ADC or DAC can also consume power during the Stop mode, unless they are disabled before entering it. To disable the ADC, the ADDIS bit must be set in the ADCx_CR register. To disable the DAC, the ENx bit in the DAC_CR register must be written to 0.

Exiting Stop mode

Refer to Table 17 for more details on how to exit Stop mode.

When exiting Stop mode by issuing an interrupt or a wakeup 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.

Table 17. Stop mode

Stop modeDescription
Mode entry

WFI (Wait for Interrupt) or WFE (Wait for Event) while:

  • – Set SLEEPDEEP bit in Arm ® Cortex ® -M4 System Control register
  • – Clear PDDS bit in Power Control register (PWR_CR)
  • – Select the voltage regulator mode by configuring LPDS bit in PWR_CR

Note: To enter Stop mode, all EXTI Line pending bits (in Pending register (EXTI_PR1) ), all peripherals interrupt pending bits and RTC Alarm flag must be reset. Otherwise, the Stop mode entry procedure is ignored and program execution continues.

If the application needs to disable the external oscillator (external clock) before entering Stop mode, the system clock source must be first switched to HSI and then clear the HSEON bit.

Otherwise, if before entering Stop mode the HSEON bit is kept at 1, the security system (CSS) feature must be enabled to detect any external oscillator (external clock) failure and avoid a malfunction when entering Stop mode.

Mode exit

If WFI was used for entry:

  • – Any EXTI Line configured in Interrupt mode (the corresponding EXTI Interrupt vector must be enabled in the NVIC).
  • – Some specific communication peripherals (USART, I2C) interrupts, when programmed in wakeup mode (the peripheral must be programmed in wakeup mode and the corresponding interrupt vector must be enabled in the NVIC).

Refer to Table 35: STM32F334xx vector table .

If WFE was used for entry:

Any EXTI Line configured in event mode. Refer to Section 12.2.3: Wakeup event management

Wakeup latencyHSI RC wakeup time + regulator wakeup time from Low-power mode

6.3.5 Standby mode

The Standby mode allows to achieve the lowest power consumption. It is based on the Cortex-M4 deepsleep mode, with the voltage regulator disabled. The 1.8 V 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 registers in the RTC domain and Standby circuitry (see Figure 6 ).

Entering Standby mode

Refer to Table 18 for more details on how to enter Standby mode.

In Standby mode, the following features can be selected by programming individual control bits:

Section 24.3: IWDG functional description in Section 24: Independent watchdog (IWDG) .

Exiting Standby mode

The microcontroller exits the Standby mode when an external reset (NRST pin), an IWDG reset, a rising edge on the WKUP pin or the rising edge of an RTC alarm occurs (see Figure 323: RTC block diagram ). All registers are reset after wakeup from Standby except for Power control/status register (PWR_CSR) .

After waking up from Standby mode, program execution restarts in the same way as after a Reset (boot pins sampling, vector reset is fetched, etc.). The SBF status flag in the Power control/status register (PWR_CSR) indicates that the MCU was in Standby mode.

Refer to Table 18 for more details on how to exit Standby mode.

Table 18. Standby mode

Standby modeDescription
Mode entryWFI (Wait for Interrupt) or WFE (Wait for Event) while:
  • – Set SLEEPDEEP in Cortex-M4 System Control register
  • – Set PDDS bit in Power Control register (PWR_CR)
  • – Clear WUF bit in Power Control/Status register (PWR_CSR)
Mode exitWKUP pin rising edge, RTC alarm event's rising edge, external Reset in NRST pin, IWDG Reset.
Wakeup latencyReset phase

I/O states in Standby mode

In Standby mode, all I/O pins are high impedance except:

Debug mode

By default, the debug connection is lost if the application puts the MCU in Stop or Standby mode while the debug features are used. This is due to the fact that the Arm ® Cortex ® -M4 core is no longer clocked.

However, by setting some configuration bits in the DBGMCU_CR register, the software can be debugged even when using the low-power modes extensively.

6.3.6 Auto-wakeup from low-power mode

The RTC can be used to wakeup the MCU from low-power mode without depending on an external interrupt (Auto-wakeup mode). The RTC provides a programmable time base for waking up from Stop or Standby mode at regular intervals. For this purpose, two of the three alternative RTC clock sources can be selected by programming the RTCSEL[1:0] bits in the RTC domain control register (RCC_BDCR) :

To wakeup from Stop mode with an RTC alarm event, it is necessary to:

To wakeup from Standby mode, there is no need to configure the EXTI Line 17.

6.4 Power control registers

The peripheral registers can be accessed by half-words (16-bit) or words (32-bit).

6.4.1 Power control register (PWR_CR)

Address offset: 0x00

Reset value: 0x0000 0000 (reset by wakeup from Standby mode)

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.DBPPLS[2:0]PVDECSBFCWUFPDDSLPDS
rwrwrwrwrwrc_w1rc_w1rwrw

Bits 31:9 Reserved, must be kept at reset value.

Bit 8 DBP : Disable RTC domain write protection.

In reset state, the RTC and backup registers are protected against parasitic write access. This bit must be set to enable write access to these registers.

Note: If the HSE divided by 128 is used as the RTC clock, this bit must remain set to 1.

Bits 7:5 PLS[2:0] : PVD level selection.

These bits are written by software to select the voltage threshold detected by the Power Voltage Detector.

Notes:

  1. 1. Refer to the electrical characteristics of the datasheet for more details.
  2. 2. Once the PVD_LOCK is enabled (for CLASS B protection) the PLS[2:0] bits cannot be programmed anymore.

Bit 4 PVDE : Power voltage detector enable.

This bit is set and cleared by software.

Bit 3 CSBF : Clear standby flag.

This bit is always read as 0.

Bit 2 CWUF : Clear wakeup flag.

This bit is always read as 0.

0: No effect

1: Clear the WUF Wakeup Flag after 2 System clock cycles . (write)

Bit 1 PDDS : Power down deepsleep.

This bit is set and cleared by software. It works together with the LPDS bit.

0: Enter Stop mode when the CPU enters Deepsleep. The regulator status depends on the LPDS bit.

1: Enter Standby mode when the CPU enters Deepsleep.

Bit 0 LPDS : Low-power deepsleep.

This bit is set and cleared by software. It works together with the PDDS bit.

0: Voltage regulator on during Stop mode

1: Voltage regulator in low-power mode during Stop mode

6.4.2 Power control/status register (PWR_CSR)

Address offset: 0x04

Reset value: 0x0000 0000 (not reset by wakeup from Standby mode)

Additional APB cycles are needed to read this register versus a standard APB read.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.EWUP3EWUP2EWUP1Res.Res.Res.Res.Res.PVDOSBFWUF
r/wr/wr/wrrr

Bits 31:11 Reserved, must be kept at reset value.

Bit 10 EWUP3 : Enable WKUP3 pin

This bit is set and cleared by software.

0: WKUP3 pin is used for general purpose I/O. An event on the WKUP3 pin does not wakeup the device from Standby mode.

1: WKUP3 pin is used for wakeup from Standby mode and forced in input pull down configuration (rising edge on WKUP3 pin wakes-up the system from Standby mode).

Note: This bit is reset by a system Reset.

Bit 9 EWUP2 : Enable WKUP2 pin

This bit is set and cleared by software.

0: WKUP2 pin is used for general purpose I/O. An event on the WKUP2 pin does not wakeup the device from Standby mode.

1: WKUP2 pin is used for wakeup from Standby mode and forced in input pull down configuration (rising edge on WKUP2 pin wakes-up the system from Standby mode).

Note: This bit is reset by a system Reset.

Bit 8 EWUP1 : Enable WKUP1 pin

This bit is set and cleared by software.

0: WKUP1 pin is used for general purpose I/O. An event on the WKUP1 pin does not wakeup the device from Standby mode.

1: WKUP1 pin is used for wakeup from Standby mode and forced in input pull down configuration (rising edge on WKUP1 pin wakes-up the system from Standby mode).

Note: This bit is reset by a system Reset.

Bits 7:3 Reserved, must be kept at reset value.

Bit 2 PVDO : PVD output

This bit is set and cleared by hardware. It is valid only if PVD is enabled by the PVDE bit.

0: \( V_{DD}/V_{DDA} \) is higher than the PVD threshold selected with the PLS[2:0] bits.

1: \( V_{DD}/V_{DDA} \) is lower than the PVD threshold selected with the PLS[2:0] bits.

Notes:

  1. 1. The PVD is stopped by Standby mode. For this reason, this bit is equal to 0 after Standby or reset until the PVDE bit is set.
  2. 2. Once the PVD is enabled and configured in the PWR_CR register, PVDO can be used to generate an interrupt through the External Interrupt controller.
  3. 3. Once the PVD_LOCK is enabled (for CLASS B protection) PVDO cannot be disabled anymore.
Bit 1 SBF : Standby flag

This bit is set by hardware and cleared only by a POR/PDR (power on reset/power down reset) or by setting the CSBF bit in the Power control register (PWR_CR)

0: Device has not been in Standby mode

1: Device has been in Standby mode

Bit 0 WUF : Wakeup flag

This bit is set by hardware and cleared by a system reset or by setting the CWUF bit in the Power control register (PWR_CR)

0: No wakeup event occurred

1: A wakeup event was received from the WKUP pin or from the RTC alarm

Note: An additional wakeup event is detected if the WKUP pin is enabled (by setting the EWUP bit) when the WKUP pin level is already high.

6.4.3 PWR register map

Table 19. PWR register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x000PWR_CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBPPLS[2:0]PVDECSBFCWUFPDDSLPDS
Reset value000000000
0x004PWR_CSRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EWUP3EWUP2EWUP1Res.Res.Res.Res.Res.Res.PVDOSBFWUF
Reset value000000

Refer to Section 2.2 on page 47 for the register boundary addresses.