Skip to main content
Visitor II
April 8, 2025
Question

difference between real measured frequency and set frequency

  • April 8, 2025
  • 4 replies
  • 699 views

Hello,

I am dealing with difference between real measured frequency and set on my Nucleo H755ZI-Q.
the measured real frequency :
APB1 76,8 MHz
APB2 76,8 MHz
recalculated
debugging frequencz SWV Core Clock 153,6 MHz

I also try printf debuged frequency:
HSE is enabled and ready.
System Clock: 480000000 Hz
APB1 Timer Clock: 120000000 Hz
APB2 Timer Clock: 120000000 Hz
APB1 Prescaler: 4
APB2 Prescaler: 4
PetrK_0-1744104643584.png

 if ((RCC->CR & RCC_CR_HSERDY) != 0) {
 printf("HSE is enabled and ready.\n");
 } else {
 printf("HSE is not enabled or ready.\n");
 }

 printf("System Clock: %lu Hz\n", HAL_RCC_GetSysClockFreq());
 printf("APB1 Timer Clock: %lu Hz\n", HAL_RCC_GetPCLK1Freq());
 printf("APB2 Timer Clock: %lu Hz\n", HAL_RCC_GetPCLK2Freq());


 uint32_t apb1_prescaler = (RCC->D2CFGR & RCC_D2CFGR_D2PPRE1) >> RCC_D2CFGR_D2PPRE1_Pos;
 uint32_t apb2_prescaler = (RCC->D2CFGR & RCC_D2CFGR_D2PPRE2) >> RCC_D2CFGR_D2PPRE2_Pos;

 printf("APB1 Prescaler: %lu\n", apb1_prescaler);
 printf("APB2 Prescaler: %lu\n", apb2_prescaler);

 uint32_t pclk1 = HAL_RCC_GetPCLK1Freq(); // Get APB1 clock
 uint32_t pclk2 = HAL_RCC_GetPCLK2Freq(); // Get APB2 clock

 printf("APB1 Clock: %lu Hz\n", pclk1);
 printf("APB2 Clock: %lu Hz\n", pclk2);

 // If prescaler > 1, Timer Clock = PCLK * 2
 if (apb1_prescaler > 3) { // Values >3 mean prescaler is applied
 printf("APB1 Timer Clock: %lu Hz\n", pclk1 * 2);
 } else {
 printf("APB1 Timer Clock: %lu Hz\n", pclk1);
 }

 if (apb2_prescaler > 3) {
 printf("APB2 Timer Clock: %lu Hz\n", pclk2 * 2);
 } else {
 printf("APB2 Timer Clock: %lu Hz\n", pclk2);
 }
 
Does anyone have any suggestion what I am doing wrong?

Edited Code Format 




    This topic has been closed for replies.

    4 replies

    ST Employee
    April 8, 2025

    Hello @PetrK

    Given that the discrepancy is huge, in the order of 50MHz for APB1 and APB2, i suspect there is maybe an issue with the measurement method! 

    PetrKAuthor
    Visitor II
    April 8, 2025

    Hello @Sarra.S ,

    thank you for the reply, I think that it is not measurement method - also have to set the timers regarding to the value ato be able run the servos. The real frequency is real.
    I also have to add the 153.6 MHz into the SWV settings to get the printf values.  

    PetrK_0-1744109072196.png

    Should it be some power issue? I am powering the Nucleo

    through USB from notebook.

    Explorer
    April 8, 2025

    In case of ambiguity, use hardware - oscilloscope verification driving MCO1 / MCO2 outputs, there 5 /6 control check points for each

    ST Employee
    April 10, 2025

    Hello @PetrK, any updates on this matter? 

    PetrKAuthor
    Visitor II
    April 14, 2025

    Hello,
    I goes through the user manual once again and realize that the inputed HSE frequency is provided by ST LINK MCO - 8 Mhz. There was set authomaticly 25 Mhz in the clock configuration. 

    https://www.st.com/resource/en/user_manual/um2408-stm32h7-nucleo144-boards-mb1363-stmicroelectronics.pdf
    7.9.1

    I followed tutorial paths for set HSE, but nobody mentioned, that it is necessary to improve the solder bridges on the board to connect the external oscillator. This is my first STM32 board, so I do not know if it is standard or something special for my H7 version.

     


    .  

    Technical Moderator
    April 14, 2025

    Hello,

    Indeed by default the HSE clock source is generated by the STLINK MCO:

    mALLEm_0-1744627580541.png

    From the board schematics, SB72 is soldered by default:

    mALLEm_0-1744628900273.png

    And the HSE crystal is not available (DNF: Do Not Fit):

    mALLEm_1-1744627839326.png

    See also this article: How to use STLINK-V3 MCO output on Nucleo boards as a precise clock source for STM32

    In any case, anyone needs to start with a ST board he needs first to download the board documentation especially the User manual and the schematic.