I have modified USB MSC Demo for STM32F103. All works fine with 8MHz crystal. But my finally application is build with 12MHz crystal.
And it is my problem. USB is not working.
1. I changed Xtall frequency in Project options to 12Mhz and define HSE_VALUE=12000000 2. I changed SetSysClockTo72()
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9); // 8Mhz x 9 = 72Mhz to RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL6); // 12Mhz x 6 = 72Mhz
3. I add RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5) to main()
...without success
I think problem is in library USB_CM3_L.lib. (builded with 8Mhz)
You probably also need to check settings in usbd_STM32F103.c USB Device driver, library should not have any dependence on CPU speed.