cancel
Showing results for 
Search instead for 
Did you mean: 

Clock configuration

gil_dobjanschi
Associate III

Hello,

I have a problem verifying the HCLK frequency for Nucleo-C562RE. I configure the clock to 144MHz (see image below).

Screenshot from 2026-04-10 12-32-56.png

When I start the application I print the HCLK frequency:

SEGGER_RTT_printf("---- MCU started at %lu[Hz] ----\n", HAL_RCC_GetHCLKFreq());

I get 48MHz:

---- MCU started at 48000000[Hz] ----

While stepping through the HAL_Init code I see that the code thinks that the clock source is LL_RCC_SYS_CLKSOURCE_STATUS_HSIDIV3 (48MHz)

uint32_t HAL_RCC_GetSYSCLKFreq(void)
{
uint32_t sysclockfreq;
uint32_t sysclk_source;

sysclk_source = LL_RCC_GetSysClkSource();
if (sysclk_source == LL_RCC_SYS_CLKSOURCE_STATUS_HSIS)
{
/* HSIS used as system clock source */
sysclockfreq = HSI_VALUE;
}
else if (sysclk_source == LL_RCC_SYS_CLKSOURCE_STATUS_HSIDIV3)
{
/* HSIS used as system clock source */
sysclockfreq = HSI_VALUE / 3U;
}

#if defined(HSE_VALUE)
else if (sysclk_source == LL_RCC_SYS_CLKSOURCE_STATUS_HSE)
{
/* HSE used as system clock source */
sysclockfreq = HSE_VALUE;
}
#endif /* HSE_VALUE */

else
{
sysclockfreq = HAL_RCC_GetPSIClockFreq();
}

return sysclockfreq;
}

 

However the clock diagram indicates HSIS as the source of clock for System Mux.

 

Help would be appreciated,

Gil

gil_dobjanschi_0-1775813742862.png


Edited to apply source code formatting - please see How to insert source code for future reference.

1 ACCEPTED SOLUTION

Accepted Solutions
STackPointer64
ST Employee

@gil_dobjanschi, RCC is disabled. Please enable it and test one more time.

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

View solution in original post

6 REPLIES 6
TDK
Super User

HSIDIV3 is the default after reset. Is it possible the clock has not been changed yet in your code? Where are you calling HAL_RCC_GetHCLKFreq in relation to clock being set? Including your IOC or code may help.

 

If you feel a post has answered your question, please click "Accept as Solution".

Hi TDK,

I called it before mx_system_init and after mx_system_init in the while(1) loop of the application. It always prints 48MHz. I attached the zipped ioc2 file. 

 

Thanks,

Gil

STackPointer64
ST Employee

Hello @gil_dobjanschi, and welcome to ST Community!

Let me check this and get back to you.

Best regards

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.
STackPointer64
ST Employee

@gil_dobjanschi, RCC is disabled. Please enable it and test one more time.

To improve visibility of answered topics, please click 'Accept as Solution' on the reply that resolved your issue or answered your question.

Hello @gil_dobjanschi

Thank you for bringing this issue to our attention.

I reported this internally.

Internal ticket number: CDM0061602.

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.
Saket_Om
gil_dobjanschi
Associate III

Hi @STackPointer64,

I confirm that by simply activating RCC the clock value is now correct. Specifically it is 48MHz on startup, before  invoking mx_system_init, and 144MHz right after mx_system_init. Thank you for the help!

 

@Saket_Om, I'm glad I can help! 

 

Regards,

Gil