AnsweredAssumed Answered

CubeMX 4.18.0 for STM32F407VG: USB Clock not enabled before calling MX_USB_Init()

Question asked by Markus Rudolf on Dec 21, 2016
Latest reply on Dec 22, 2016 by Nesrine M

When I generate a project with USB CDC Device Class and FreeRTOS, enumeration fails because the clock to the USB peripheral is not enabled before calling MX_USB_DEVICE_Init(). If I insert the code as follows

 

void StartDefaultTask(void const * argument)
{
  /* init code for LWIP */
  MX_LWIP_Init();
  __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); <----- INSERT THIS LINE
  /* init code for USB_DEVICE */
  MX_USB_DEVICE_Init();

 

  /* USER CODE BEGIN 5 */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END 5 */
}

in the Default Task it works like a charm. Please consider fixing that as it took me quite some time to figure out what was wrong.

Outcomes