AnsweredAssumed Answered

stm32f429 usb msc enumeration fails in FS mode connected at FS pins.

Question asked by kumar.chandan on Sep 9, 2015
Latest reply on Sep 9, 2015 by kumar.chandan

Using STM32Cube_FW_F4_V1.6.0 demonstration code for STM32F429I-Disco board, in which USBH is configured to operate in full speed mode on HS pins.

I am having custom board where USB MSC device is interfaced with FS pins (DM-PA11, DP-PA12, VBUS-PA9 and USB-ID/USB-OC pins are connected but not configured for now). There is a enable pin at PC6 connected to /EN pin of STMPS2161STR.

Now, I have modified the demo code in usb_conf.c file as below.

#define HOST_POWERSW_PORT                 GPIOC
#define HOST_POWERSW_VBUS                 GPIO_PIN_6

/* Private variables ---------------------------------------------------------*/
HCD_HandleTypeDef hhcd;

void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd)
  /* On STM32F429I-DISCO, USB OTG HS Core will operate in Full speed mode */
  GPIO_InitTypeDef  GPIO_InitStruct;
  /*EMBEDDED Physical interface*/
  GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
  GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 
  /* Configure  VBUS Pin */
  GPIO_InitStruct.Pin = GPIO_PIN_9;
  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);    
  /* Enable USB HS Clocks */ 
  /* Configure Power Switch Vbus Pin */
  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  /* By Default, DISABLE is needed on output of the Power Switch */
  USBH_Delay(200);   /* Delay is need for stabilising the Vbus Low */
  /* Set USBHS Interrupt to the lowest priority */
  HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0);
  /* Enable USBFS Interrupt */

void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd)
  /* Disable USB HS Clocks */ 

USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
  /*Set LL Driver parameters */
  hhcd.Instance = USB_OTG_FS;
  hhcd.Init.Host_channels = 7; 
  hhcd.Init.dma_enable = 1;
  hhcd.Init.low_power_enable = 0;
  hhcd.Init.phy_itface = HCD_PHY_EMBEDDED; 
  hhcd.Init.Sof_enable = 0;
  hhcd.Init.speed = HCD_SPEED_FULL;
  hhcd.Init.use_external_vbus = 1;  
  /* Link The driver to the stack */
  hhcd.pData = phost;
  phost->pData = &hhcd;
  /*Initialize LL Driver */
  if (HAL_HCD_Init(&hhcd) != HAL_OK)
    return USBH_FAIL;
  USBH_LL_SetTimer (phost, HAL_HCD_GetCurrentFrame(&hhcd));
  return USBH_OK;

and in stm32f4xx_it.c file.

void OTG_FS_IRQHandler(void)

Now, the result is:

in usb_core.c USBH_Process(), it doesn't pass this condition. It always shows USBH_BUSY. During this process, pulses are observed at DM and DP pins.

    /* Check for enumeration status */  
    if ( USBH_HandleEnum(phost) == USBH_OK)
      /* The function shall return USBH_OK when full enumeration is complete */
      USBH_UsrLog ("Enumeration done.");

In interrupt part, upon connecting USB Device it shows SOF interrupt.

This project is based on FreeRTOS.

What could be the possible reasons for this? Kindly help.