Skip to main content
turboscrew
Senior III
October 13, 2017
Question

STM32L476 MSI + PLL

  • October 13, 2017
  • 11 replies
  • 2518 views
Posted on October 13, 2017 at 19:37

What is the magic that PLL doesn't want to let go of MSI?

I've been trying to switch MSI + PLL ON/OFF during STOP2 mode (to save battery), but the MSI + PLL hangs on for about 15 milliseconds. I'm first switching onto HSI16 to 'free' PLL and then turning OFF the PLL and then setting PLL clock source to NONE. I've also tried turning the SAI1 and SAI2 PLLs off before disabling the main PLL, but that didn't seem to be the problem. Also going to STOP2  with PLL left ON seems to make it hard to get the MSI + PLL started after wakeup.

The PLL comes off from HSE normally.

#stm32l476 #pll #msi
This topic has been closed for replies.

11 replies

Tesla DeLorean
Guru
October 15, 2017
Posted on October 15, 2017 at 18:21

Not sure the value of switching to HSI, MSI should surely already be running, can't you switch to that? The PLL needs to be off to be configured, you should check it's state and review RCC register settings in the various start up conditions.

16ms to start and switch to the PLL does seem excessive based on my reading of the DS and RM

Debuggers may interfere with these processes, would recommend instrumenting via GPIO and USART to quantify modes and start times.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
turboscrew
Senior III
October 15, 2017
Posted on October 15, 2017 at 23:26

I'm switching to HSI to get system clock off the PLL. Otherwise the PLL and MSI can't be stopped. I'm trying to disable PLL and make its clock source NONE for faster setup after wakeup. If I started with MSI I couldn't put the PLL on it...

I wonder what state the clocks/PLLs would be if I didn't stop anything, but just let the stop2 to disable them...

It's hard to check the clock/PLL status bits, because the uC doesn't go to stop2 if debugger is attached. I don't have time to set up an USART either. :(

Maybe I'll try with leds.. (there are 2 leds).

16ms to start and switch to the PLL does seem excessive based on my reading of the DS and RM

And the funny thing is that with HSE+PLL there is no such problem It gets ON and OFF in less than 3 ms.

turboscrew
Senior III
October 16, 2017
Posted on October 16, 2017 at 18:40

Any idea why this doesn't work?

  __HAL_RCC_PLLSAI1_DISABLE();

  __HAL_RCC_PLLSAI2_DISABLE();

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

  RCC_OscInitStruct.MSIState = RCC_HSI_ON;

  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_NONE;

  HAL_RCC_OscConfig(&RCC_OscInitStruct);

 

  HAL_RCC_ClockConfig(...)

 

  __HAL_RCC_PLL_DISABLE()

/* let the stop2 kill the clocks and PLLs */

(go to stop2 for about 100 ms)

(wakeup)

/* just in case... */

  __HAL_RCC_PLLSAI1_DISABLE();

  __HAL_RCC_PLLSAI2_DISABLE();

  __HAL_RCC_PLL_DISABLE()

  __HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_NONE)

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;

  RCC_OscInitStruct.MSIState = RCC_MSI_ON;

  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;

  HAL_RCC_OscConfig(&RCC_OscInitStruct);

  HAL_RCC_ClockConfig(...)

...

Tesla DeLorean
Guru
October 16, 2017
Posted on October 16, 2017 at 19:13

You fill the PLL parameters some place? Enable asserts check if it throws errors or ends up in a handler or while loop.

Fully initialize structures out of wake.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
turboscrew
Senior III
October 16, 2017
Posted on October 16, 2017 at 20:13

I just didn't put everything there, and I've gone through the HAL-sources. It doesn't hang into any of the asserts. (Checked that with 'fake sleep' - a loop waiting for the wakeup interrupt to set a flag instead of going to stop2.) It looks like the chip doesn't wake up at all. (The wakeup is done by LPTIM1 on LSE.)

Maybe I should have put at least dots...

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;

... (PLL parameters)

HAL_RCC_OscConfig(&RCC_OscInitStruct);

Oh, and the not waking up... the core current consumption stays in a couple of microamps.

And HSI16 is set as the wakeup clock.