cancel
Showing results for 
Search instead for 
Did you mean: 

Do PWR and SYSCFG need to be clocked permanently?

Diez.R.
Associate II

Hi all:

I have a general question about whether STM32 peripherals need to be clocked permanently.

I am using an STM32G0 at the moment, and I am disabling the USB C Power Delivery "Dead Battery" feature, in order to make sure that the internal 5k1 pull-downs on the UCPDx_CCx pins (PA8, PB15, PD0, PD2) are disabled:

LL_SYSCFG_DisableDBATT( LL_SYSCFG_UCPD1_STROBE | LL_SYSCFG_UCPD2_STROBE );

Nothing indicates that you need to clock any peripheral to do that, but LL_SYSCFG_DisableDBATT() writes to SYSCFG->CFGR1, so I am guessing that you need to clock SYSCFG:

LL_APB2_GRP1_EnableClock( LL_APB2_GRP1_PERIPH_SYSCFG );

However, other people also clock PWR. I may be because other families STM32G4 and STM32L5 disable those pull-down resistors in a different way:

PWR->CR3 |= PWR_CR3_UCPD_DBDIS; // See LL_PWR_DisableUCPDDeadBattery().

So I wonder whether clocking PWR is necessary on the STM32G0 to do that task.

The code which STM32CubeMX generates for the STM32G0 does clock PWR too, probably because it calls HAL_PWREx_ControlVoltageScaling().

However, the voltage scaling upon reset in PWR_CR1 ist already the right level "VOS = 01: Range 1 (high-performance range)" for the maximum 64 Mhz operation, so there is no need to set it at all.

The HAL code waits until the desired power level has been reached:

while (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))

But I wonder whether that is necessary. I would be silly that the STM32G0 starts configured with the high-performance range, but before its power regulator has actually reached the proper level. I could not find that detail in the documentation.

After all these ramblings, I am also wondering whether such peripherals need to be clocked permanently. Reference manual RM0444 states:

"When the clock to a peripheral or I/O port is not active, the read and write accesses to its registers are not effective."

I would expect the registers to read as 0 if the peripheral is not clocked then.

However, reading PWR->CR1 when PWR is not clocked does not return 0, but a plausible value, at least on the STM32G0.

Say I just need to check some register values, or to set some options, only once on start-up. Can I clock those peripherals, read and/or write the affected bits, and then stop the clock? Or would they stop functioning properly?

Obviously, a USART or an SPI need a clock to operate, but does SYSCFG or PWR?

Let's change now to the STM32F4 family. Its Power Controller (PWR) has a Power Supply Supervisor (for brown-out reset). If configure it, and then stop the PWR clock, will the configured brown-out reset stop working?

Thanks in advance,
  rdiez

1 REPLY 1
FBL
ST Employee

Hi @Diez.R. 

> "When the clock to a peripheral or I/O port is not active, the read and write accesses to its registers are not effective"

The statement about clock dependency primarily affects the ability to read/write registers, not the persistence of configurations.

For example, when disabling USB-C Power Delivery dead battery pull-downs via SYSCFG, PWR registers, the configuration persists even after the peripheral clock is disabled. This is because such configurations typically involve static hardware gating that do not require continuous clocking.

To conclude, exceptions exist where registers retain values even when the clock is off, depending on the hardware peripheral's design.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.