cancel
Showing results for 
Search instead for 
Did you mean: 

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

saochandan
Associate
Posted on September 09, 2015 at 09:02

Hi.

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.

&sharpdefine HOST_POWERSW_PORT                 GPIOC

&sharpdefine 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*/

  __HAL_RCC_GPIOA_CLK_ENABLE();

  __HAL_RCC_GPIOC_CLK_ENABLE();

  

  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 */ 

  __HAL_RCC_USB_OTG_FS_CLK_ENABLE();

  

  /* Configure Power Switch Vbus Pin */

  GPIO_InitStruct.Pin = HOST_POWERSW_VBUS;

  GPIO_InitStruct.Speed = GPIO_SPEED_FAST;

  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  HAL_GPIO_Init(HOST_POWERSW_PORT,&GPIO_InitStruct);

  

  /* By Default, DISABLE is needed on output of the Power Switch */

  HAL_GPIO_WritePin(HOST_POWERSW_PORT, HOST_POWERSW_VBUS, GPIO_PIN_SET);

  

  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 */

  HAL_NVIC_EnableIRQ(OTG_FS_IRQn);

}

void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd)

{

  /* Disable USB HS Clocks */ 

  __HAL_RCC_USB_OTG_FS_CLK_DISABLE();

}

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)

{

  HAL_HCD_IRQHandler(&hhcd);

}

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.

case HOST_ENUMERATION:     

    /* 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.

Thanks,

Chandan

#enumeration #stm32f29 #usbmsc
1 REPLY 1
saochandan
Associate
Posted on September 09, 2015 at 12:28

upon setting hhcd.Init.dma_enable = 0;

it works. I spend 3-4 days to find out this. But still in doubt, how this caused the problem.