[STM32L4] [RCC] Re-configure MSI Clock once SystemClock_Config() is done
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-04 5:19 AM
Posted on August 04, 2016 at 14:19
Hi,
I am trying to run my system at 4 MHz SYSCLK having PLLCLK as source.PLL has MSI as Source configured at 4 MHz.This configuration is done in SystemClock_Config() in main().Now, I am trying to re-configure the clocks of the PLL so that the SYSCLK has 48 MHz and SDMMC1 and USB has 48 MHz via PLLQ, since I want to run the the SDCard and USB in Device Mode.I am able to reconfigure the clocks, oscillators and peripheral clocks by calling the HAL_RCCEx_DisableMSIPLLMode().But my USB is not getting enumerated. I am getting USB unrecognized.So is there any graceful way to bump up the PLL clocks on the fly i.e. after the SystemClock_Config() is called.I read the Reference Manual and it is mentioned that on System Reset, MSI is selected as Default Source and I confirmed that the same thing is done in the code.But then how can I update my PLL block parameters if I want to keep MSI as clock source for PLLCLK and PLLCLK as source for SYSCLK.Thanks,Sunny #msi #stm32l4 #rcc #clockconfig
Labels:
- Labels:
-
RCC
-
STM32L4 series
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-04 6:11 AM
Posted on August 04, 2016 at 15:11
So is there any graceful way to bump up the PLL clocks on the fly i.e. after the SystemClock_Config() is called.
In my experience no, you have to turn off the PLL to change the parameters, and you can't randomly change the input to the PLL. So you have to go through a sequence of switching to another source, turn it off, reconfigure, and come back. Suggest you start by configuring at 48 MHz and get to a slower SYSCLK (AHB/APB) by dividing the clock source down. And then using the dividers to gear the clocking up/down.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-08-05 12:09 AM
Posted on August 05, 2016 at 09:09
Hi Clive,
Thank you for the pointer.I am able to configure the MSI and PLL clocks on the fly now.For reference, below are the steps:Since I am using MSI as PLL source, and PLLCLK as SYSCLK, we cannot directly change PLL Parameters (Refer Reference Manual -> RCC Chapter -> Clocks -> PLL).- So we need to configure firstly, MSI as SYSCLK by HAL_RCC_ClockConfig().
- Configure HSI Oscillator + PLL OFF by HAL_RCC_OscConfig().
- Configure HSI as SYSCLK by HAL_RCC_ClockConfig().
- Now re-configure MSI + PLL, MSI as PLL Source by HAL_RCC_OscConfig().
- Then re-configure the PLLCLK as SYSCLK.
