Skip to main content
MOB1
Associate II
Jan 9, 2023 5:53 AM UTC
Solved

Setting MSI,HSI or HSE and configure clock speed of SYSCLK ,HCLK and other cloks.

Hello, I have a stm32wb55 nucleo board,

I want to know that whats is the logic behind that , In reference manual it says 

After a system reset, the MSI oscillator, at 4 MHz, is selected .

Lets say I want to use HSI or HSE for specific application and I want to set SYSCLK, HCLKs and other clocks .

How can I implement a code that configure HSI,HSE selection and SYSCLK etc.

I want to do that using LL(low layer libraries).

Thanks for your helps

This topic has been closed for replies.
Pavel A.
Pavel A.Best answer
Jan 9, 2023 11:33 AM UTC

In CubeMX, Project manager tab->advanced, select to use HAL or LL for RCC code.

4 replies

gbm
Super User
Jan 9, 2023 8:23 AM UTC

Read the RefMan section on RCC module. See the description of control register and PLL configuration register.

Write the code:

  • turn on the required clock source
  • wait for it to stabilize
  • set the PLL config and turn it on
  • set the Flash wait states in FLASH->ACR
  • wait for PLL to stabilize
  • switch to PLL

Each item above translates to a single C statement. That's it. No HAL or LL needed. To determine the values for PLL config, you may use CubeMX clock configuration tab.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
MOB1
MOB1Author
Associate II
Jan 9, 2023 10:29 AM UTC

When we configure project via using cube ide or MX configuration manager we can easily set clock speeds.I saw some funcitons in low layer LL libraries like LL_RCC_HSI_Enable (void ). I want to do that steps with low layer library is there some functions to set clock configs?.

Pavel A.
Pavel A.Best answer
Jan 9, 2023 11:33 AM UTC

In CubeMX, Project manager tab->advanced, select to use HAL or LL for RCC code.