LL_RCC_GetSystemClocksFreq API migration

In HAL1, the function void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks) is called to update the structure fields for retrieving the frequencies of different on-chip clocks, including System, AHB, APB1, and APB2 bus clocks. In HAL2, we must use the unitary LL APIs for each clock selected, as demonstrated in the table below

HAL1

HAL2

/* Declare a variable of type LL_RCC_ClocksTypeDef */
LL_RCC_ClocksTypeDef RCC_Clocks;

/* Call the function to get the clock frequencies */
LL_RCC_GetSystemClocksFreq(&RCC_Clocks);
 uint32_t source;
 uint32_t system_frequency;
 uint32_t hclk_frequency;
 uint32_t pclk1_frequency;
 uint32_t pclk2_frequency;
 uint32_t pclk3_frequency;


/* In the first step get the system clock source */
source = LL_RCC_GetSysClkSource();

// After determining the source, call one of the following functions, which depend on the source found

/* MSIS used as system clock source */
 system_frequency = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                  ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                   LL_RCC_MSIS_GetRange() :
                                   LL_RCC_MSIS_GetRangeAfterStandby()));

/* HSI used as system clock  source */
system_frequency = HSI_VALUE;

/* HSE used as system clock  source */
system_frequency = HSE_VALUE;

/* PLL1 used as system clock  source */
/* get the pll clock source */
uint32_t pllinputfreq;
uint32_t pllsource;

pllsource = LL_RCC_PLL1_GetMainSource();

/* Based on the source found, perform one of the following steps for determinete pllinputfreq */
/* MSIS used as PLL1 clock source */
pllinputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                     ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                      LL_RCC_MSIS_GetRange() :
                                      LL_RCC_MSIS_GetRangeAfterStandby()));

/* HSI used as PLL1 clock source */
pllinputfreq = HSI_VALUE;

/* HSE used as PLL1 clock source */
pllinputfreq = HSE_VALUE;

/* Get SYSCLK frequency */
system_frequency = LL_RCC_CALC_PLL1CLK_FREQ(pllinputfreq, LL_RCC_PLL1_GetDivider(),
                                          LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetR());

/* HCLK clock frequency */
hclk_frequency = LL_RCC_CALC_HCLK_FREQ(system_frequency, LL_RCC_GetAHBPrescaler());

/* PCLK1 clock frequency */
pclk1_frequency = LL_RCC_CALC_PCLK1_FREQ(hclk_frequency, LL_RCC_GetAPB1Prescaler());

/* PCLK2 clock frequency */
pclk2_frequency = LL_RCC_CALC_PCLK2_FREQ(hclk_frequency, LL_RCC_GetAPB2Prescaler());

/* PCLK3 clock frequency */
pclk3_frequency = LL_RCC_CALC_PCLK3_FREQ(hclk_frequency, LL_RCC_GetAPB3Prescaler());

Note

Note1: For all LL_RCC_GetPPPClockFreq() calls, follow the same sequence detailed in the previous section to obtain the pclk1_frequency, pclk2_frequency, pclk4_frequency, or system_frequency.

Note

Note2: If the peripheral’s clock source is unknown, call the LL_RCC_GetPPPClockSource() functions.

LL_RCC_GetPPPClockFreq APIs migration

LL_RCC_GetUSARTClockFreq

HAL1

HAL2

In HAL1 to get the USART frequency, you need to call the function LL_RCC_GetUSARTClockFreq.
uint32_t usart_frequency = LL_RCC_GetUSARTClockFreq(LL_RCC_USART1_CLKSOURCE);

Note

This function is valid for all LL_RCC_USARTx_CLKSOURCE (x=1,2,3,6)

In HAL2 according to USARTx_CLKSOURCE this function is replaced by the following:

 uint32_t usart_frequency;

/* if USARTx Clock source is System Clock */

 usart_frequency = system_frequency;

 /* if USARTx Clock source is PCLK2 */

 usart_frequency = pclk2_frequency;

 /* if USARTx Clock source is LSE Osc. */

 usart_frequency = LSE_VALUE;

 /* if USARTx Clock source is HSI Osc. */

 usart_frequency = HSI_VALUE;

LL_RCC_GetUARTClockFreq

HAL1

HAL2

In HAL1 to get the UART frequency, you need to call the function LL_RCC_GetUARTClockFreq.
uint32_t uart_frequency = LL_RCC_GetUARTClockFreq(LL_RCC_UART4_CLKSOURCE);

Note

This function is valid for all LL_RCC_UARTx_CLKSOURCE (x=4,5)

In HAL2 according to UARTx_CLKSOURCE this function is replaced by the following:
 uint32_t uart_frequency;

/* if UARTx Clock source is System Clock */

 uart_frequency = system_frequency;

 /* if UARTx Clock source is PCLK1 */

 uart_frequency = pclk2_frequency;

 /* if UARTx Clock source is LSE Osc. */

 uart_frequency = LSE_VALUE;

 /* if UARTx Clock source is HSI Osc. */

 uart_frequency = HSI_VALUE;

LL_RCC_GetSPIClockFreq

HAL1

HAL2

In HAL1 to get the SPI frequency, you need to call the function LL_RCC_GetSPIClockFreq.
uint32_t spi_frequency = LL_RCC_GetSPIClockFreq(LL_RCC_SPI1_CLKSOURCE);

Note

This function is valid for all LL_RCC_SPIx_CLKSOURCE (x=1,2,3)

In HAL2 according to SPIx_CLKSOURCE this function is replaced by the following:
 uint32_t spi_frequency;

/* if SPIx Clock is System Clock */
 spi_frequency = system_frequency;

 /* if SPIx Clock is PCLK2 */
 spi_frequency = hclk_frequency;

 /* if SPIx Clock is MSIK Osc. */
 spi_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                      ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                        LL_RCC_MSIK_GetRange() :
                                        LL_RCC_MSIK_GetRangeAfterStandby()));

 /* if SPIx Clock is HSI Osc. */
 spi_frequency = HSI_VALUE;

LL_RCC_GetI2CClockFreq

HAL1

HAL2

In HAL1 to get the I2C frequency, you need to call the function LL_RCC_GetI2CClockFreq.
uint32_t i2c_frequency = LL_RCC_GetI2CClockFreq(LL_RCC_I2C1_CLKSOURCE);

Note

This function is valid for all LL_RCC_I2Cx_CLKSOURCE (x=1,2,3,4,5,6)

In HAL2 according to I2Cx_CLKSOURCE this function is replaced by the following:
 uint32_t i2c_frequency;

/* if I2Cx Clock is System Clock */
 i2c_frequency = system_frequency;

 /* if I2Cx Clock is PCLK1 */
 i2c_frequency = pclk1_frequency;

 /* if I2Cx Clock is MSI Osc. */
 i2c_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                      ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                        LL_RCC_MSIK_GetRange() :
                                        LL_RCC_MSIK_GetRangeAfterStandby()));

 /* if I2Cx Clock is HSIOsc. */
 i2c_frequency = HSI_VALUE;

LL_RCC_GetLPUARTClockFreq

HAL1

HAL2

In HAL1 to get the LPUART frequency, you need to call the function LL_RCC_GetLPUARTClockFreq.
uint32_t lpuart_frequency = LL_RCC_GetLPUARTClockFreq(LL_RCC_LPUART1_CLKSOURCE);

Note

This function is valid for LL_RCC_LPUART1_CLKSOURCE

In HAL2 according to LPUARTx_CLKSOURCE this function is replaced by the following:

 uint32_t lpuart_frequency;

/* if LPUARTx Clock source is System Clock */
 lpuart_frequency = system_frequency;

 /* if LPUARTx Clock source is PCLK3 */
 lpuart_frequency = pclk3_frequency;

 /* if LPUARTx Clock source is LSE Osc. */
 lpuart_frequency = LSE_VALUE;

 /* if LPUARTx Clock source is HSI Osc. */
 lpuart_frequency = HSI_VALUE;

LL_RCC_GetLPTIMClockFreq

HAL1

HAL2

In HAL1 to get the LPTIM frequency, you need to call the function LL_RCC_GetLPTIMClockFreq.
uint32_t lptim_frequency = LL_RCC_GetLPTIMClockFreq(LL_RCC_LPTIM1_CLKSOURCE);

Note

This function is valid for all LL_RCC_LPTIMx_CLKSOURCE (x=1,2,34)

In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following:

 uint32_t lptim_frequency;

/* if LPTIMx Clock is LSI Osc. */
 lptim_frequency = LSI_VALUE;

/* if LPTIMx Clock is HSI Osc. */
 lptim_frequency = HSI_VALUE;

/* if LPTIMx Clock is LSE Osc. */
 lptim_frequency = LSE_VALUE;

/* if LPTIMx Clock is MSI Osc. */
 lptim_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                         ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                          LL_RCC_MSIK_GetRange() :
                                          LL_RCC_MSIK_GetRangeAfterStandby()));

LL_RCC_GetSAIClockFreq

HAL1

HAL2

In HAL1 to get the SAI frequency, you need to call the function LL_RCC_GetSAIClockFreq.
uint32_t sai_frequency = LL_RCC_GetSAIClockFreq(LL_RCC_SAI1_CLKSOURCE);

Note

This function is valid for all LL_RCC_SAIx_CLKSOURCE (x=1,2)

In HAL2 according to SAIx_CLKSOURCE this function is replaced by the following sequences:

uint32_t sai_frequency;
uint32_t pll2outputfreq;
uint32_t pll2source;
uint32_t pll2inputfreq;

/* SAI1 Clock source is PLL2 */
/*PLL2 should be ready and PLL2 SAIDomain is enabled */
pll2source = LL_RCC_PLL2_GetSource();

// According to the source of PLL2 call one of this following sequences

/* MSI used as PLLSAI1 clock source */
pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                              ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                LL_RCC_MSIS_GetRange() :
                                LL_RCC_MSIS_GetRangeAfterStandby()));

/* HSI used as PLL2 clock source */
pll2inputfreq = HSI_VALUE;

/* HSE used as PLL2 clock source */
pll2inputfreq = HSE_VALUE

/* Before calculating the PLL output frequencies, please consult the reference manual
for the STM32 series to verify the conditions applicable to each PLL divider */
pll2outputfreq = LL_RCC_CALC_PLL2CLK_SAI_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                              LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP())
sai_frequency = pll2outputfreq;


 /* SAI1 Clock source is PLL3 */
 /*PLL3 should be ready and PLL3 SAIDomain is enabled */

 uint32_t pll3outputfreq;
 uint32_t pll3source;
 uint32_t pll3inputfreq
 pll3source = LL_RCC_PLL3_GetSource();
 // According to the source of PLL3 call one of this following sequence
 /* MSI used as PLL3 clock source */
 pll3inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                       ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                        LL_RCC_MSIS_GetRange() :
                                        LL_RCC_MSIS_GetRangeAfterStandby()));

 /* HSI used as PLL3 clock source */
 pll3inputfreq = HSI_VALUE;
 /* HSE used as PLL3 clock source */
 pll3inputfreq = HSE_VALUE
 /* Before calculating the PLL output frequencies, please consult the reference manual
 for the STM32 series to verify the conditions applicable to each PLL divider */
 pll3outputfreq = LL_RCC_CALC_PLL3CLK_SAI_FREQ(pll3inputfreq, LL_RCC_PLL3_GetDivider(),
                                               LL_RCC_PLL3_GetN(), LL_RCC_PLL3_GetP())
 sai_frequency = pll3outputfreq;


 /* SAI1 Clock source is PLL1 */
 /*PLL1 should be ready and PLL1 SAIDomain is enabled */

    uint32_t pll1outputfreq;
    uint32_t pll1source;
    uint32_t pll1inputfreq;

    pll1source = LL_RCC_PLL1_GetSource();
    // According to the source of PLL3 call one of this following sequences

    /* MSI used as PLL3 clock source */
    pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                          ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                           LL_RCC_MSIS_GetRange() :
                                           LL_RCC_MSIS_GetRangeAfterStandby()));

    /* HSI used as PLL1 clock source */
    pll1inputfreq = HSI_VALUE;
    /* HSE used as PLL1 clock source */
    pll1inputfreq = HSE_VALUE;

    /* Before calculating the PLL output frequencies, please consult the reference manual
    for the STM32 series to verify the conditions applicable to each PLL divider */
    pll1outputfreq = LL_RCC_CALC_PLL1CLK_SAI_FREQ(pll1inputfreq, LL_RCC_PLL1_GetDivider(),
                                                  LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetP());

    sai_frequency = pll1outputfreq;

/* SAIx Clock source is External input */
sai_frequency = EXTERNAL_SAIx_CLOCK_VALUE;

LL_RCC_GetSDMMCKernelClockFreq

HAL1

HAL2

In HAL1 to get the SDMMC kernel clock frequency, you need to call the function LL_RCC_GetSDMMCKernelClockFreq
uint32_t sdmmc_frequency = LL_RCC_GetSDMMCKernelClockFreq(LL_RCC_SDMMC_KERNELCLKSOURCE);

In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following sequence:

 uint32_t sdmmc_frequency;

/* if SDMMC Clock is 48MHz clock from internal multiplexor. */

 sdmmc_frequency = LL_RCC_GetSDMMCClockFreq(LL_RCC_SDMMC_CLKSOURCE); /*refer to LL_RCC_GetSDMMCClockFreq() migration section

/* if SDMMC Clock is PLL1. */

 uint32_t pll1outputfreq;
 uint32_t pll1source;
 uint32_t pll1inputfreq
 pll1source = LL_RCC_PLL1_GetSource();

 // According to the source of PLL3 call one of this following sequence

 /* MSI used as PLL3 clock source */
 pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                       ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                        LL_RCC_MSIS_GetRange() :
                                        LL_RCC_MSIS_GetRangeAfterStandby()));

 /* HSI used as PLL1 clock source */
 pll1inputfreq = HSI_VALUE;
 /* HSE used as PLL1 clock source */
 pll1inputfreq = HSE_VALUE
 /* Before calculating the PLL output frequencies, please consult the reference manual
 for the STM32 series to verify the conditions applicable to each PLL divider */
 pll1outputfreq = LL_RCC_CALC_PLL1CLK_SAI_FREQ(pll11inputfreq, LL_RCC_PLL1_GetDivider(),
                                               LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetP())
 sdmmc_frequency = pll1outputfreq;

LL_RCC_GetSDMMCClockFreq

HAL1

HAL2

In HAL1 to get the SDMMC clock frequency, you need to call the function LL_RCC_GetSDMMCClockFreq
uint32_t sdmmc_frequency = LL_RCC_GetSDMMCClockFreq(LL_RCC_SDMMC_CLKSOURCE);

In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following:

 uint32_t sdmmc_frequency;

/* PLL2 clock used as SDMMC12 clock source */
 uint32_t pll2outputfreq;
 uint32_t pll2source;
 uint32_t pll2inputfreq;

 /* SAI1 Clock source is PLL2 */
 /*PLL2 should be ready and PLL2 48MDomain is enabled */
     pll2source = LL_RCC_PLL2_GetSource();

     // According to the source of PLL2 call one of this following sequences

     /* MSI used as PLL2 clock source */
     pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                   ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                    LL_RCC_MSIS_GetRange() :
                                    LL_RCC_MSIS_GetRangeAfterStandby()));

     /* HSI used as PLL2 clock source */
     pll2inputfreq = HSI_VALUE;

     /* HSE used as PLL2 clock source */
     pll2inputfreq = HSE_VALUE;

     /* Before calculating the PLL output frequencies, please consult the reference manual
     for the STM32 series to verify the conditions applicable to each PLL divider */
     pll2outputfreq = LL_RCC_CALC_PLL2CLK_48M_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                                   LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

     sai_frequency = pll2outputfreq;
 }

 uint32_t pll1outputfreq;
 uint32_t pll1source;
 uint32_t pll1inputfreq

 /*PLL1 should be ready */
 pll1source = LL_RCC_PLL1_GetSource();

 // According to the source of PLL1 call one of this following sequence

 /* MSI used as PLL1 clock source */
 pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                       ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                        LL_RCC_MSIS_GetRange() :
                                        LL_RCC_MSIS_GetRangeAfterStandby()));

 /* HSI used as PLL1 clock source */
 pll1inputfreq = HSI_VALUE;

 /* HSE used as PLL1 clock source */
 pll1inputfreq = HSE_VALUE

 /* Before calculating the PLL output frequencies, please consult the reference manual
 for the STM32 series to verify the conditions applicable to each PLL divider */
 pll1outputfreq = LL_RCC_CALC_PLL1CLK_48M_FREQ(pll12inputfreq, LL_RCC_PLL1_GetDivider(),
                                               LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetP())
 sdmmc_frequency = pll1outputfreq;

 /* MSIK clock used as SDMMC12 clock source */
 sdmmc_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                        ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                          LL_RCC_MSIK_GetRange() :
                                          LL_RCC_MSIK_GetRangeAfterStandby()));

 /* HSI48 used as SDMMC1 clock source */
 sdmmc_frequency = HSI48_VALUE;

LL_RCC_GetRNGClockFreq

HAL1

HAL2

In HAL1 to get the RNG frequency, you need to call the function LL_RCC_GetRNGClockFreq.
uint32_t rng_frequency = LL_RCC_GetRNGClockFreq(LL_RCC_RNG_CLKSOURCE);

In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following:

 uint32_t rng_frequency;

/* HSI clock used as RNG clock source */

 rng_frequency = HSI_VALUE;

/* HSI48 clock used as RNG clock source */

 rng_frequency = HSI48_VALUE;

/* HSI48DIV2 clock used as RNG clock source */

 rng_frequency = (HSI48_VALUE / 2U);

LL_RCC_GetUSBClockFreq

HAL1

HAL2

In HAL1 to get the USB clock frequency, you need to call the function LL_RCC_GetUSBClockFreq
uint32_t usb_frequency = LL_RCC_GetUSBClockFreq(LL_RCC_GetUSBClockFreq);

In HAL2 this function is replaced by the following implementation:

 uint32_t usb_frequency;

/* PLL2 clock used as USB clock source */

 uint32_t pll2outputfreq;
 uint32_t pll2source;
 uint32_t pll2inputfreq;

 /* USB Clock source is PLL2 */
 /*PLL2 should be ready and PLL2 48MDomain is enabled */

     pll2source = LL_RCC_PLL2_GetSource();
     // According to the source of PLL2 call one of this following sequences

     /* MSI used as PLL2 clock source */
     pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                   ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                    LL_RCC_MSIS_GetRange() :
                                    LL_RCC_MSIS_GetRangeAfterStandby()));

     /* HSI used as PLL2 clock source */
     pll2inputfreq = HSI_VALUE;
     /* HSE used as PLL2 clock source */
     pll2inputfreq = HSE_VALUE;

     /* Before calculating the PLL output frequencies, please consult the reference manual
     for the STM32 series to verify the conditions applicable to each PLL divider */
     pll2outputfreq = LL_RCC_CALC_PLL2CLK_48M_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                                   LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

     usb_frequency = pll2outputfreq;

 uint32_t pll1outputfreq;
 uint32_t pll1source;
 uint32_t pll1inputfreq

 /*PLL1 should be ready and PLL1 48MDomain is enabled */
 pll1source = LL_RCC_PLL1_GetSource();

 // According to the source of PLL3 call one of this following sequence

 /* MSI used as PLL3 clock source */
 pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                       ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                        LL_RCC_MSIS_GetRange() :
                                        LL_RCC_MSIS_GetRangeAfterStandby()));

 /* HSI used as PLL1 clock source */
 pll1inputfreq = HSI_VALUE;

 /* HSE used as PLL1 clock source */
 pll1inputfreq = HSE_VALUE

 /* Before calculating the PLL output frequencies, please consult the reference manual
 for the STM32 series to verify the conditions applicable to each PLL divider */
 pll1outputfreq = LL_RCC_CALC_PLL1CLK_SAI_FREQ(pll12inputfreq, LL_RCC_PLL1_GetDivider(),
                                               LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetP())
 usb_frequency = pll1outputfreq;

 /* MSIK clock used as USB clock source */
 usb_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                        ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                          LL_RCC_MSIK_GetRange() :
                                          LL_RCC_MSIK_GetRangeAfterStandby()));

 /* HSI48 used as USB clock source */
 usb_frequency = HSI48_VALUE;

LL_RCC_GetADCDACClockFreq

HAL1

HAL2

In HAL1 to get the ADC/DAC clock frequency, you need to call the function LL_RCC_GetADCDACClockFreq
uint32_t adcdac_frequency = LL_RCC_GetADCDACClockFreq(LL_RCC_ADCDAC_CLKSOURCE);

In HAL2 this function is replaced by the following implementation:

 uint32_t adcdac_frequency;

 /* ADCDAC Clock is SYSCLK */
  adcdac_frequency = system_frequency

/* PLL2 clock used as ADCDAC clock source */

 uint32_t pll2outputfreq;
 uint32_t pll2source;
 uint32_t pll2inputfreq;

 /* ADC/DAC Clock source is PLL2 */
 /*PLL2 should be ready and PLL2 48MDomain is enabled */
 pll2source = LL_RCC_PLL2_GetSource();
 // According to the source of PLL2 call one of this following sequences

 /* MSI used as PLL2 clock source */
 pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                               ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                LL_RCC_MSIS_GetRange() :
                                LL_RCC_MSIS_GetRangeAfterStandby()));

 /* HSI used as PLL2 clock source */
 pll2inputfreq = HSI_VALUE;
 /* HSE used as PLL2 clock source */
 pll2inputfreq = HSE_VALUE;

 /* Before calculating the PLL output frequencies, please consult the reference manual
 for the STM32 series to verify the conditions applicable to each PLL divider */
 pll2outputfreq = LL_RCC_CALC_PLL2CLK_ADC_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                               LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

 adcdac_frequency = pll2outputfreq;

 /*HSI clock used as ADCDAC clock source */
 adcdac_frequency = HSI_VALUE;

 /*HSE clock used as ADCDAC clock source */
 adcdac_frequency = HSE_VALUE;

 /* MSIK clock used as ADCDAC clock source */

 adcdac_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                         ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                           LL_RCC_MSIK_GetRange() :
                                           LL_RCC_MSIK_GetRangeAfterStandby()));

LL_RCC_GetLTDCClockFreq

HAL1

HAL2

In HAL1 to get the LTDC frequency, you need to call the function LL_RCC_GetLTDCClockFreq.
uint32_t ltdc_frequency = LL_RCC_GetLTDCClockFreq(LL_RCC_LTDC_CLKSOURCE);

In HAL2 according this function is replaced by the following sequence:

uint32_t ltdc_frequency;
uint32_t pll2outputfreq;
uint32_t pll2source;
uint32_t pll2inputfreq;

/* LTDC Clock source is PLL2 */
/*PLL2 should be ready and PLL2 ADCDomain is enabled */
pll2source = LL_RCC_PLL2_GetSource();

// According to the source of PLL2 call one of this following sequences

/* MSI used as PLL2 clock source */
pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                              ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                               LL_RCC_MSIS_GetRange() :
                               LL_RCC_MSIS_GetRangeAfterStandby()));

/* HSI used as PLL2 clock source */
pll2inputfreq = HSI_VALUE;

/* HSE used as PLL2 clock source */
pll2inputfreq = HSE_VALUE;

/* Before calculating the PLL output frequencies, please consult the reference manual
for the STM32 series to verify the conditions applicable to each PLL divider */
pll2outputfreq = LL_RCC_CALC_PLL2CLK_ADC_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                              LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

ltdc_frequency = pll2outputfreq;


 /* LTDC Clock source is PLL3 */
 /*PLL3 should be ready and PLL3 HSPILTDCDomain is enabled */


uint32_t pll3outputfreq;
uint32_t pll3source;
uint32_t pll3inputfreq;

pll3source = LL_RCC_PLL3_GetSource();
// According to the source of PLL3 call one of this following sequences

/* MSI used as PLL3 clock source */
pll3inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                      ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                       LL_RCC_MSIS_GetRange() :
                                       LL_RCC_MSIS_GetRangeAfterStandby()));

/* HSI used as PLL3 clock source */
pll3inputfreq = HSI_VALUE;
/* HSE used as PLL3 clock source */
pll3inputfreq = HSE_VALUE;

/* Before calculating the PLL output frequencies, please consult the reference manual
for the STM32 series to verify the conditions applicable to each PLL divider */
pll3outputfreq = LL_RCC_CALC_PLL3CLK_HSPI_LTDC_FREQ(pll2inputfreq, LL_RCC_PLL3_GetDivider(),
                                                    LL_RCC_PLL3_GetN(), LL_RCC_PLL3_GetP());

ltdc_frequency = pll3outputfreq;

LL_RCC_GetHSPIClockFreq

HAL1

HAL2

In HAL1 to get the HSPI clock frequency, you need to call the function LL_RCC_GetHSPIClockFreq
uint32_t hspi_frequency = LL_RCC_GetHSPIClockFreq(LL_RCC_HSPI_CLKSOURCE);

In HAL2 this function is replaced by the following implementation:

 uint32_t hspi_frequency;

 /* HSPI Clock is SYSCLK */
  hspi_frequency = system_frequency

/* PLL1 clock used as HSPI clock source */

 uint32_t pll1outputfreq;
 uint32_t pll1source;
 uint32_t pll1inputfreq;


     /*PLL1 should be ready and PLL1 HSPILTDCDomain is enabled */
     pll2source = LL_RCC_PLL2_GetSource();
     // According to the source of PLL1 call one of this following sequences

     /* MSI used as PLL1 clock source */
     pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                   ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                    LL_RCC_MSIS_GetRange() :
                                    LL_RCC_MSIS_GetRangeAfterStandby()));

     /* HSI used as PLL1 clock source */
     pll1inputfreq = HSI_VALUE;

     /* HSE used as PLL1 clock source */
     pll1inputfreq = HSE_VALUE;

     /* Before calculating the PLL output frequencies, please consult the reference manual
     for the STM32 series to verify the conditions applicable to each PLL divider */
     pll2outputfreq = LL_RCC_CALC_PLL1CLK_HSPI_LTDC_FREQ(pll1inputfreq, LL_RCC_PLL2_GetDivider(),
                                                   LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

     adcdac_frequency = pll2outputfreq;


    /* PLL2 clock used as HSPI clock source */

    uint32_t pll2outputfreq;
    uint32_t pll2source;
    uint32_t pll2inputfreq;

     /* HSPI Clock source is PLL2 */

     /*PLL1 should be ready and PLL1 HSPILTDCDomain is enabled */

     pll2source = LL_RCC_PLL2_GetSource();
     // According to the source of PLL2 call one of this following sequences

     /* MSI used as PLL2 clock source */
     pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                   ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                    LL_RCC_MSIS_GetRange() :
                                    LL_RCC_MSIS_GetRangeAfterStandby()));

     /* HSI used as PLL2 clock source */
     pll2inputfreq = HSI_VALUE;

     /* HSE used as PLL2 clock source */
     pll2inputfreq = HSE_VALUE;

     /* Before calculating the PLL output frequencies, please consult the reference manual
     for the STM32 series to verify the conditions applicable to each PLL divider */
     pll2outputfreq = LL_RCC_CALC_PLL2CLK_HSPI_LTDC_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                                   LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

     hspi_frequency = pll2outputfreq;
 }

  /* HSPI Clock source is PLL3 */
  /* PLL3 should be ready */

     uint32_t pll3outputfreq;
     uint32_t pll3source;
     uint32_t pll3inputfreq;

     pll3source = LL_RCC_PLL3_GetSource();
     // According to the source of PLL3 call one of this following sequences

     /* MSI used as PLL3 clock source */
     pll3inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                           ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                            LL_RCC_MSIS_GetRange() :
                                            LL_RCC_MSIS_GetRangeAfterStandby()));

     /* HSI used as PLL3 clock source */
     pll3inputfreq = HSI_VALUE;
     /* HSE used as PLL3 clock source */
     pll3inputfreq = HSE_VALUE;

     /* Before calculating the PLL output frequencies, please consult the reference manual
     for the STM32 series to verify the conditions applicable to each PLL divider */
     pll3outputfreq = LL_RCC_CALC_PLL3CLK_HSPI_LTDC_FREQ(pll3inputfreq, LL_RCC_PLL3_GetDivider(),
                                                   LL_RCC_PLL3_GetN(), LL_RCC_PLL3_GetP());

     hspi_frequency = pll3outputfreq;

LL_RCC_GetFDCANClockFreq

HAL1

HAL2

In HAL1 to get the HSPI clock frequency, you need to call the function LL_RCC_GetFDCANClockFreq
uint32_t hspi_frequency = LL_RCC_GetFDCANClockFreq(LL_RCC_FDCAN_CLKSOURCE);

In HAL2 this function is replaced by the following implementation:

uint32_t fdcan_frequency;
uint32_t pll2outputfreq;
uint32_t pll2source;
uint32_t pll2inputfreq;

/* FDCAN Clock source is PLL2 */

/*PLL1 should be ready and PLL1 SAIDomain is enabled */

    pll2source = LL_RCC_PLL2_GetSource();
    // According to the source of PLL2 call one of this following sequences

    /* MSI used as PLLSAI1 clock source */
    pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                  ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                   LL_RCC_MSIS_GetRange() :
                                   LL_RCC_MSIS_GetRangeAfterStandby()));

    /* HSI used as PLL2 clock source */
    pll2inputfreq = HSI_VALUE;
    /* HSE used as PLL2 clock source */
    pll2inputfreq = HSE_VALUE;

    /* Before calculating the PLL output frequencies, please consult the reference manual
    for the STM32 series to verify the conditions applicable to each PLL divider */
    pll2outputfreq = LL_RCC_CALC_PLL2CLK_SAI_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                                  LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

    fdcan_frequency = pll2outputfreq;
}

LL_RCC_GetMDF1ClockFreq

HAL1

HAL2

In HAL1 to get the MDF1 clock frequency, you need to call the function LL_RCC_GetMDF1ClockFreq
uint32_t mdf1_frequency = LL_RCC_GetMDF1ClockFreq(LL_RCC_MDF1_CLKSOURCE);

In HAL2 this function is replaced by the following implementation:

/* MDF1 Clock is SYSCLK */
mdf1_frequency = system_frequency

/* MDF1 Clock is PLL1 */
uint32_t pll1outputfreq;
uint32_t pll1source;
uint32_t pll1inputfreq

pll1source = LL_RCC_PLL1_GetSource();
// According to the source of PLL3 call one of this following sequence
/* MSI used as PLL3 clock source */
pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                      ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                       LL_RCC_MSIS_GetRange() :
                                       LL_RCC_MSIS_GetRangeAfterStandby()));

/* HSI used as PLL1 clock source */
pll1inputfreq = HSI_VALUE;

/* HSE used as PLL1 clock source */
pll1inputfreq = HSE_VALUE

/* Before calculating the PLL output frequencies, please consult the reference manual
for the STM32 series to verify the conditions applicable to each PLL divider */
pll1outputfreq = LL_RCC_CALC_PLL1CLK_SAI_FREQ(pll1inputfreq, LL_RCC_PLL1_GetDivider(),
                                              LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetP())
mdf1_frequency = pll1outputfreq;

/* MDF1 Clock is PLL3 */
uint32_t pll3outputfreq;
uint32_t pll3source;
uint32_t pll3inputfreq;

pll3source = LL_RCC_PLL3_GetSource();
// According to the source of PLL3 call one of this following sequences

/* MSI used as PLL3 clock source */
pll3inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                      ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                       LL_RCC_MSIS_GetRange() :
                                       LL_RCC_MSIS_GetRangeAfterStandby()));

/* HSI used as PLL3 clock source */
pll3inputfreq = HSI_VALUE;
/* HSE used as PLL3 clock source */
pll3inputfreq = HSE_VALUE;

/* Before calculating the PLL output frequencies, please consult the reference manual
for the STM32 series to verify the conditions applicable to each PLL divider */
MDF1_frequency = LL_RCC_CALC_PLL3CLK_48M_FREQ(pll3inputfreq, LL_RCC_PLL3_GetDivider(),
                                                    LL_RCC_PLL3_GetN(), LL_RCC_PLL3_GetP());

ltdc_frequency = pll3outputfreq;

/* External input clock used as MDF1 clock source */
MDF1_frequency = EXTERNAL_SAI1_CLOCK_VALUE;

/* MDF1 Clock is MSIK */
MDF1_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                     ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                      LL_RCC_MSIK_GetRange() :
                                      LL_RCC_MSIK_GetRangeAfterStandby()));

LL_RCC_GetADF1ClockFreq

HAL1

HAL2

In HAL1 to get the FDCAN clock frequency, you need to call the function LL_RCC_GetADF1ClockFreq
uint32_t hspi_frequency = LL_RCC_GetADF1ClockFreq(LL_RCC_ADF1_CLKSOURCE);

In HAL2 this function is replaced by the following implementation:

 /* ADF1 Clock source is PLL3 */
    /*PLL3 should be ready and PLL1 SAIDomain is enabled */

    uint32_t pll3outputfreq;
    uint32_t pll3source;
    uint32_t pll3inputfreq;

    pll3source = LL_RCC_PLL3_GetSource();
    // According to the source of PLL3 call one of this following sequences

    /* MSI used as PLL3 clock source */
    pll3inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                          ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                           LL_RCC_MSIS_GetRange() :
                                           LL_RCC_MSIS_GetRangeAfterStandby()));

    /* HSI used as PLL3 clock source */
    pll3inputfreq = HSI_VALUE;
    /* HSE used as PLL3 clock source */
    pll3inputfreq = HSE_VALUE;

    /* Before calculating the PLL output frequencies, please consult the reference manual
    for the STM32 series to verify the conditions applicable to each PLL divider */
    pll3outputfreq = LL_RCC_CALC_PLL3CLK_SAI_FREQ(pll3inputfreq, LL_RCC_PLL3_GetDivider(),
                                                  LL_RCC_PLL3_GetN(), LL_RCC_PLL3_GetP());

    adf1_frequency = pll3outputfreq;



 /* ADF1 Clock source is PLL1 */
    /*PLL1 should be ready and PLL1 SAIDomain is enabled */

    uint32_t pll1outputfreq;
    uint32_t pll1source;
    uint32_t pll1inputfreq;

    pll1source = LL_RCC_PLL1_GetSource();
    // According to the source of PLL1 call one of this following sequences

    /* MSI used as PLL1 clock source */
    pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                          ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                           LL_RCC_MSIS_GetRange() :
                                           LL_RCC_MSIS_GetRangeAfterStandby()));

    /* HSI used as PLL1 clock source */
    pll1inputfreq = HSI_VALUE;

    /* HSE used as PLL1 clock source */
    pll1inputfreq = HSE_VALUE;

    /* Before calculating the PLL output frequencies, please consult the reference manual
    for the STM32 series to verify the conditions applicable to each PLL divider */
    pll1outputfreq = LL_RCC_CALC_PLL1CLK_SAI_FREQ(pll1inputfreq, LL_RCC_PLL1_GetDivider(),
                                                  LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetP());

    adf1_frequency = pll1outputfreq;



/* External input clock used as ADF1 clock source */
adf1_frequency = EXTERNAL_SAI1_CLOCK_VALUE;

/* ADF1 Clock is MSIK */
adf1_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                     ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                       LL_RCC_MSIK_GetRange() :
                                       LL_RCC_MSIK_GetRangeAfterStandby()));

LL_RCC_GetDSIClockFreq

HAL1

HAL2

In HAL1 to get the DSI frequency, you need to call the function LL_RCC_GetDSIClockFreq.
uint32_t dsi_frequency = LL_RCC_GetDSIClockFreq(LL_RCC_DSI_CLKSOURCE);

In HAL2 this function is replaced by the following sequences:

uint32_t dsi_frequency;

 /* DSI Clock source is PLL3 */
 /*PLL1 should be ready and PLL1 SAIDomain is enabled */

    uint32_t pll3outputfreq;
    uint32_t pll3source;
    uint32_t pll3inputfreq;

    pll3source = LL_RCC_PLL3_GetSource();
    // According to the source of PLL3 call one of this following sequences

    /* MSI used as PLL3 clock source */
    pll3inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                          ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                           LL_RCC_MSIS_GetRange() :
                                           LL_RCC_MSIS_GetRangeAfterStandby()));

    /* HSI used as PLL3 clock source */
    pll3inputfreq = HSI_VALUE;
    /* HSE used as PLL3 clock source */
    pll3inputfreq = HSE_VALUE;

    /* Before calculating the PLL output frequencies, please consult the reference manual
    for the STM32 series to verify the conditions applicable to each PLL divider */
    pll3outputfreq = LL_RCC_CALC_PLL3CLK_SAI_FREQ(pll3inputfreq, LL_RCC_PLL3_GetDivider(),
                                                  LL_RCC_PLL3_GetN(), LL_RCC_PLL3_GetP());

    dsi_frequency = pll3outputfreq;

LL_RCC_GetSAESClockFreq

HAL1

HAL2

In HAL1 to get the SAES clock frequency, you need to call the function LL_RCC_GetSAESClockFreq
uint32_t saes_frequency = LL_RCC_GetSAESClockFreq(LL_RCC_SAES_CLKSOURCE);

In HAL2 this function is replaced by the following implementation:

uint32_t saes_frequency;

/* SHSI clock used as SAES clock source */
saes_frequency = HSI_VALUE;

/* SHSIDIV2 clock used as SAES clock source */
saes_frequency = (HSI_VALUE/2);

LL_RCC_GetOCTOSPIClockFreq

HAL1

HAL2

In HAL1 to get the OCTOSPI frequency, you need to call the function LL_RCC_GetOCTOSPIClockFreq.
uint32_t sai_frequency = LL_RCC_GetOCTOSPIClockFreq(LL_RCC_OCTOSPI_CLKSOURCE);

In HAL2 this function is replaced by the following sequences:

uint32_t octospi_frequency;
uint32_t pll1outputfreq;
uint32_t pll1source;
uint32_t pll1inputfreq;

/* OCTOSPI Clock source is PLL1 */
    pll1source = LL_RCC_PLL1_GetSource();

    // According to the source of PLL1 call one of this following sequences

    /* MSI used as PLL1 clock source */
    pll1inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                  ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                   LL_RCC_MSIS_GetRange() :
                                   LL_RCC_MSIS_GetRangeAfterStandby()));

    /* HSI used as PLL1 clock source */
    pll1inputfreq = HSI_VALUE;
    /* HSE used as PLL1 clock source */
    pll1inputfreq = HSE_VALUE;

    /* Before calculating the PLL output frequencies, please consult the reference manual
    for the STM32 series to verify the conditions applicable to each PLL divider */
    pll1outputfreq = LL_RCC_CALC_PLL1CLK_48M_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                                  LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

    octospi_frequency = pll1outputfreq;
}

 /* OCTOSPI Clock source is PLL2 */
    uint32_t pll2outputfreq;
    uint32_t pll2source;
    uint32_t pll2inputfreq;

    pll2source = LL_RCC_PLL2_GetSource();
    // According to the source of PLL2 call one of this following sequences

    /* MSI used as PLL2 clock source */
    pll2inputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                          ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                           LL_RCC_MSIS_GetRange() :
                                           LL_RCC_MSIS_GetRangeAfterStandby()));

    /* HSI used as PLL2 clock source */
    pll3inputfreq = HSI_VALUE;

    /* HSE used as PLL2 clock source */
    pll3inputfreq = HSE_VALUE;

    /* Before calculating the PLL output frequencies, please consult the reference manual
    for the STM32 series to verify the conditions applicable to each PLL divider */
    pll2outputfreq = LL_RCC_CALC_PLL3CLK_SAI_FREQ(pll2inputfreq, LL_RCC_PLL2_GetDivider(),
                                                  LL_RCC_PLL2_GetN(), LL_RCC_PLL2_GetP());

    octospi_frequency = pll2outputfreq;



 /* MSIk clock used as OCTOSPI clock */
 octospi_frequency = LL_RCC_CALC_MSIK_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
                                            ((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
                                              LL_RCC_MSIK_GetRange() :
                                              LL_RCC_MSIK_GetRangeAfterStandby()));

LL_RCC_GetDAC1ClockFreq

HAL1

HAL2

In HAL1 to get the DAC1 clock frequency, you need to call the function LL_RCC_GetDAC1ClockFreq
uint32_t dac1_frequency = LL_RCC_GetDAC1ClockFreq(LL_RCC_DAC1_CLKSOURCE);

In HAL2 this function is replaced by the following implementation:

uint32_t dac1_frequency;

/* DAC1 Clock is LSE  */
dac1_frequency = LSE_VALUE;

/* DAC1 Clock is LSI  */
dac1_frequency = LSI_VALUE;