2023-01-10 10:13 PM
Hello,
I want to know difference between SYSCLK and SystemCoreClok.
When ı try to configure clock of different peripherals I saw terms SYSCLK and SystemCoreClock. I use MSI for SYSCLK which is configured to 32MHZ and for cpu1 ı divided sysclk by 4 and get 8 MHz . So my HCLK freq is 8 MHZ.
On the code I saw something like
LL_SetSystemCoreClock(8000000);
and for SYSCLK ı saw something like
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_MSI);
What ı want to understand is that if I set core clock 8MHz is it mean that the SYSCLK is also 8 MHZ or not.
Solved! Go to Solution.
2023-01-10 11:38 PM
Hello @MOB
First let me thank you for posting.
SYSCLK and SystemCoreClock are related, but they have different meanings.
SYSCLK is the system clock, which is used to drive the core and the buses of the microcontroller. It is typically sourced from a clock generator (such as the MSI or PLL), and its frequency can be configured by the user. In your case, you have configured the SYSCLK to be sourced from the MSI, and to have a frequency of 32 MHz
SystemCoreClock, on the other hand, is a variable that holds the current core clock frequency. It is used to configure the clock of different peripherals, and it is automatically updated by the system to reflect the current SYSCLK frequency. In your case, you have configured the core clock to be 8 MHz, which is obtained by dividing the SYSCLK by 4.
The LL_SetSystemCoreClock(8000000); set this global variable, SystemCoreClock to 8000000 so that it reflects the current frequency of the core clock.
The LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_MSI); is setting the Source of SYSCLK to MSI.
So, to sum up, the SYSCLK is 32MHz and the SystemCoreClock is 8MHz. The SYSCLK is used to drive the core and the buses of the microcontroller, while the SystemCoreClock is used to configure the clock of different peripherals, and it holds the current core clock frequency.
Thx
Ghofrane
2023-01-10 11:38 PM
Hello @MOB
First let me thank you for posting.
SYSCLK and SystemCoreClock are related, but they have different meanings.
SYSCLK is the system clock, which is used to drive the core and the buses of the microcontroller. It is typically sourced from a clock generator (such as the MSI or PLL), and its frequency can be configured by the user. In your case, you have configured the SYSCLK to be sourced from the MSI, and to have a frequency of 32 MHz
SystemCoreClock, on the other hand, is a variable that holds the current core clock frequency. It is used to configure the clock of different peripherals, and it is automatically updated by the system to reflect the current SYSCLK frequency. In your case, you have configured the core clock to be 8 MHz, which is obtained by dividing the SYSCLK by 4.
The LL_SetSystemCoreClock(8000000); set this global variable, SystemCoreClock to 8000000 so that it reflects the current frequency of the core clock.
The LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_MSI); is setting the Source of SYSCLK to MSI.
So, to sum up, the SYSCLK is 32MHz and the SystemCoreClock is 8MHz. The SYSCLK is used to drive the core and the buses of the microcontroller, while the SystemCoreClock is used to configure the clock of different peripherals, and it holds the current core clock frequency.
Thx
Ghofrane
2023-01-10 11:50 PM
Thank you so much :smiling_cat_face_with_heart_eyes: