STM32F7 Discovery USB CDC using CubeMX
It's a pity that STMicroelectronics does not include clock enable code in their libraries. The solution is to enable USB OTG clock by calling __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); in a MX_USB_DEVICE_Init() routine or before.