Skip to main content
Visitor II
September 2, 2025
Solved

STM32CubeMX H7S3 RCC_CCIPR1 incorrect initalization code generation

  • September 2, 2025
  • 3 replies
  • 372 views

When using PLL3Q as input with a frequency of 32MHz for USBPHY I have a RCC_CCIPR1 register initialized at value 0x2a00 when entreing USB_CoreReset function that is not correct (should be 0x2b00).

Best answer by FBL

Hi @PHT 

An internal ticket is submitted to dedicated team for a fix in driver! (220943) It seems  LL_RCC_USBREF_CLKSOURCE is not implemented in current HAL/LL driver.

3 replies

Ghofrane GSOURI
Technical Moderator
September 5, 2025

Hello @PHT 

Could you please share your IOC file? Having access to it will help me investigate the issue more thoroughly and gain a better understanding of your configuration.

THX

Ghofrane

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.
FBLBest answer
Technical Moderator
October 31, 2025

Hi @PHT 

An internal ticket is submitted to dedicated team for a fix in driver! (220943) It seems  LL_RCC_USBREF_CLKSOURCE is not implemented in current HAL/LL driver.

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.Best regards,FBL
Technical Moderator
November 18, 2025

Hi @PHT 

Here is the updates to avoid blocking your progress while waiting for the official fix in the next release: 

  1. Add RCCEx_USBREF_Clock_Source here, as follows :
     uint32_t UsbRefClockSelection; /*!< Specifies USBREF clock frequency.
     This parameter can be a value of @ref RCCEx_USBREF_Clock_Source */​
  2. Here,  define RCCEx_USBREF_Clock_Sources to be selected as follows:

    /** @defgroup RCCEx_USBREF_Clock_Source Peripheral USBREF clock frequency selection
     * @{
     */
    #define RCC_USBREFCLKSOURCE_16M ((uint32_t)(RCC_CCIPR1_USBREFCKSEL_1 | RCC_CCIPR1_USBREFCKSEL_0))
    #define RCC_USBREFCLKSOURCE_19_2M ((uint32_t)RCC_CCIPR1_USBREFCKSEL_3)
    #define RCC_USBREFCLKSOURCE_20M ((uint32_t)(RCC_CCIPR1_USBREFCKSEL_3 | RCC_CCIPR1_USBREFCKSEL_0))
    #define RCC_USBREFCLKSOURCE_24M ((uint32_t)(RCC_CCIPR1_USBREFCKSEL_3 | RCC_CCIPR1_USBREFCKSEL_1))
    #define RCC_USBREFCLKSOURCE_26M ((uint32_t)(RCC_CCIPR1_USBREFCKSEL_3 |\
     RCC_CCIPR1_USBREFCKSEL_2 | RCC_CCIPR1_USBREFCKSEL_1))
    #define RCC_USBREFCLKSOURCE_32M ((uint32_t)(RCC_CCIPR1_USBREFCKSEL_3 |\
     RCC_CCIPR1_USBREFCKSEL_1 | RCC_CCIPR1_USBREFCKSEL_0))
    /**
     * @}
     */​

     

  3. Now, you can add macros for configuring and reading USBREF clock sources
    
    /** @brief Macro to configure the USBREF clock frequency
     * @param __USBREF_CLKSOURCE__ specifies the USBREF clock frequency.
     * This parameter can be one of the following values:
     * @arg RCC_USBREFCLKSOURCE_16M 16 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_19_2M 19.2 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_20M 20 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_24M 24 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_26M 26 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_32M 32 MHz clock selected as USBPHYC clock
     */
    #define __HAL_RCC_USBREF_CONFIG(__USBREF_CLKSOURCE__) \
     MODIFY_REG(RCC->CCIPR1, RCC_CCIPR1_USBREFCKSEL, (uint32_t)(__USBREF_CLKSOURCE__))
    
    /** @brief Macro to get the USBREF clock frequency.
     * @retval The clock source can be one of the following values:
     * @arg RCC_USBREFCLKSOURCE_16M 16 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_19_2M 19.2 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_20M 20 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_24M 24 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_26M 26 MHz clock selected as USBPHYC clock
     * @arg RCC_USBREFCLKSOURCE_32M 32 MHz clock selected as USBPHYC clock
     */
    #define __HAL_RCC_GET_USBREF_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR1, RCC_CCIPR1_USBREFCKSEL)))
    ​
  4. Now,  here add check for validated clock source
    #define IS_RCC_USBREFCLKSOURCE(__SOURCE__) \
     (((__SOURCE__) == RCC_USBREFCLKSOURCE_16M) || \
     ((__SOURCE__) == RCC_USBREFCLKSOURCE_19_2M) || \
     ((__SOURCE__) == RCC_USBREFCLKSOURCE_20M) || \
     ((__SOURCE__) == RCC_USBREFCLKSOURCE_24M) || \
     ((__SOURCE__) == RCC_USBREFCLKSOURCE_26M) || \
     ((__SOURCE__) == RCC_USBREFCLKSOURCE_32M))
    ​
  5. In hal_rcc_ex.c, modify the RCC structure to use USBREF clock selection here :
     assert_param(IS_RCC_USBREFCLKSOURCE(PeriphClkInit->UsbRefClockSelection));​
    then set it here.
     /* Set USBPHYC reference clock frequency*/
     __HAL_RCC_USBREF_CONFIG(PeriphClkInit->UsbRefClockSelection);​
  6.  Now, for example here in application code, to implement the initialization, of PeriphClkInit.UsbRefClockSelection = RCC_USBREFCLKSOURCE_32M; within the HAL_PCD_MspInit() function, here is an example
     /** Initializes the peripherals clock
     */
     PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USBPHYC;
     PeriphClkInit.UsbPhycClockSelection = RCC_USBPHYCCLKSOURCE_HSE;
     PeriphClkInit.UsbRefClockSelection = RCC_USBREFCLKSOURCE_32M;
     if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
     {
     Error_Handler();
     }
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.Best regards,FBL