PLL Setting for USB CDC Question

Sysprogs forums Forums VisualGDB PLL Setting for USB CDC Question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6690
    KNguyen
    Participant

    Hi,

    I trying to run the USB CDC Example but the PC does not recognize the USB.

    I think it is the PLL Setting for the clock and I not sure how to set it up.

    Can some one help.

    My hardware use a 12MHz for the HSE and STM32105VC.

    // Configure PPL Clock

    oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; // Select HSE as Oscillator (12MHz input)

    oscinitstruct.HSEState = RCC_HSE_ON; // Enable the HSE block

    oscinitstruct.PLL2.HSEPrediv2Value = RCC_HSE_PREDIV2_DIV3; // Divide by 3 => 4MHz

    oscinitstruct.PLL2.PLL2MUL = RCC_PLL2_MUL10; // Multiply by 10 => 40MHz

    oscinitstruct.PLL2.PLL2State = RCC_PLL2_ON; // Enable the PLL2 block

    oscinitstruct.Prediv1Source = RCC_PREDIV1_SOURCE_PLL2; // Select PLL2 (40MHz)

    oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV5; // Divide by PPL2 by 5 => 8MHz

    oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; // as clock source the PLL block

    oscinitstruct.PLL.PLLState = RCC_PLL_ON; // Enable the PLL block

    oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; // Multiply by 9 => 72MHz

    HAL_RCC_OscConfig(&oscinitstruct);

    /* USB clock selection */

    rccperiphclkinit.PeriphClockSelection = RCC_PERIPHCLK_USB; // Set USB clock to

    rccperiphclkinit.UsbClockSelection = RCC_USBPLLCLK_DIV3; // 72 x2 /3 = 48MHz

    HAL_RCCEx_PeriphCLKConfig(&rccperiphclkinit);

    The question is what clock the USB need? I thought the USB uses a 480MHz clock.

    Thanks.

     

    • This topic was modified 9 years, 4 months ago by support.
    #6692
    support
    Keymaster

    Hi,

    Normally the USB clock needs to be 48 MHz. Please use the STM32CubeMX tool to validate your clock parameters:

    You can read here about integrating code generated by STM32CubeMX into VisualGDB projects.

     

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.