AnsweredAssumed Answered

likely bug in cubemx code generation for stm32f103x usb clock

Question asked by noobee on Apr 24, 2015
Latest reply on Jul 1, 2015 by STM32Cube-T
hi

trying to enable USB VCP on the stm32f103c8 device, used the cubemx generator, selected USB device and CDC class, updated the clock generation page so that it generated the 48MHz clock for USB (HSE Prediv=1, PLLsourceMux=HSE, PLLMul=6, USB Prescaler = 1).

however, the generated code in SystemClock_Config() still did not set up the USB clock correctly. in particular, the following lines are needed but missing:

RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;

i added them in and was then able to get my PC to recognize the USB (COM) device after that.

incidentally, the code is generated for the stm32f303 device, which was how i found the discrepancy.

thanks



Outcomes