cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F411, STM32CubeMX, USB Device for CDC

bardeen
Associate
Posted on November 26, 2014 at 08:09

STM32F411RCTx, LQFP64

When using STM32CubeMX Ver4.4 to generate USB Device only code for CDC class, initialization is fine but cannot connect to PC (host).

The STM32CubeMX generated code also has same problem as MDK-ARM 5.xx USB device driver. It could be resulting from ''

power saving mode

'' or ''

VBus voltage sensing

'' for STM32F411.

For example,

   *****************************************************************

      * @file           : usbd_conf.c

      * @date           : 24/11/2014 18:53:54   

      * @version        : v1.0_Cube

      * @brief          : This file implements the board support package for the USB device library

***********************************************************************

        USBD_StatusTypeDef  USBD_LL_Init (USBD_HandleTypeDef *pdev)

        { 

          /* Init USB_IP */

          if (pdev->id == DEVICE_FS) {

          /* Link The driver to the stack */

          hpcd_USB_OTG_FS.pData = pdev;

          pdev->pData = &hpcd_USB_OTG_FS; 

          

          hpcd_USB_OTG_FS.Instance = USB_OTG_FS;

          hpcd_USB_OTG_FS.Init.dev_endpoints = 7;

          hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;

          hpcd_USB_OTG_FS.Init.dma_enable = DISABLE;

          hpcd_USB_OTG_FS.Init.ep0_mps = DEP0CTL_MPS_64;

          hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;

          hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;

         

//hpcd_USB_OTG_FS.Init.low_power_enable = ENABLE;

 hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;

          hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;

          hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;

          hpcd_USB_OTG_FS.Init.use_external_vbus = DISABLE;

          HAL_PCD_Init(&hpcd_USB_OTG_FS);

        

          HAL_PCD_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);

          HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);

          HAL_PCD_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);

          }

          return USBD_OK;

        }

At line 268 of usbd_conf.c, disable the ''low_power_enable'' flag then USB device can work fine...

I have no idea what is going on USB driver for STM32F411 body. Please address me if you have similar issue.

Thank you!

#usb-cdc #stm32f411
2 REPLIES 2
matija
Associate
Posted on December 07, 2014 at 14:03

I ran into the same problem with STM32F407VG. Disabling the low power mode helped me a bit too. The COM port is now registered, but the device manager is reporting ''{Operation Failed} The requested operation was unsuccessful. C0000001''. Any further info would be appreciated.

Regards,

Matija
matija
Associate
Posted on December 07, 2014 at 15:35

Found my problem! The heap was too small (0x0200). After I increased it, everything started working.