cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with USB Hish Speed on STM32F746G-Disco board

ANDRE THEVENIN
Associate II

Hello,

I have problems with some STM32F746G-DISCO boards on the USB High speed port.

I have built an application which uses the USB-HS in host mode. On one board, it works fine, but on other ones I cannot make it work.

To test the hardware and not my software, I have built an application with STM32CubeMX with

-> a HID device on USB-FS

-> a VCP device on USB-HS

I have added the necessary initialization sequences for the HS port in the code generated by CubeMX (code below).

The result works fine on one board, I see both devices on the PC

But with other boardss, I see only the FS device.

The board which works is dated 1735 and marked JOVE JVE-M2 94V-0 E232940

One board which does not work is dated 1815 and marked SS-3 14V-0 E229342

Are there some design differences which could explain the problem ?

My initialization code

void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)

{

 GPIO_InitTypeDef GPIO_InitStruct;

 if(pcdHandle->Instance==USB_OTG_FS)

 {

 /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */

 /* USER CODE END USB_OTG_FS_MspInit 0 */

   /**USB_OTG_FS GPIO Configuration   

   PA12    ------> USB_OTG_FS_DP

   PA11    ------> USB_OTG_FS_DM

   */

   GPIO_InitStruct.Pin = OTG_FS_P_Pin|OTG_FS_N_Pin;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;

   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

   /* Peripheral clock enable */

   __HAL_RCC_USB_OTG_FS_CLK_ENABLE();

   /* Peripheral interrupt init */

   HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0);

   HAL_NVIC_EnableIRQ(OTG_FS_IRQn);

 /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */

 /* USER CODE END USB_OTG_FS_MspInit 1 */

 }

 if(pcdHandle->Instance==USB_OTG_HS)

 {

 /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */

 /* USER CODE END USB_OTG_HS_MspInit 0 */

   /**USB_OTG_HS GPIO Configuration

   PB5    ------> USB_OTG_HS_ULPI_D7

   PI11    ------> USB_OTG_HS_ULPI_DIR

   PH4    ------> USB_OTG_HS_ULPI_NXT

   PB13    ------> USB_OTG_HS_ULPI_D6

   PB12    ------> USB_OTG_HS_ULPI_D5

   PC0    ------> USB_OTG_HS_ULPI_STP

   PA5    ------> USB_OTG_HS_ULPI_CK

   PB10    ------> USB_OTG_HS_ULPI_D3

   PA3    ------> USB_OTG_HS_ULPI_D0

   PB1    ------> USB_OTG_HS_ULPI_D2

   PB0    ------> USB_OTG_HS_ULPI_D1

   PB11    ------> USB_OTG_HS_ULPI_D4

   */

   GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_13|GPIO_PIN_12|GPIO_PIN_10

                         |GPIO_PIN_1|GPIO_PIN_0|GPIO_PIN_11;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;

   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_2;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;

   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_4;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;

   HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_0;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;

   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_3;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS;

   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

   /* Peripheral clock enable */

   __HAL_RCC_USB_OTG_HS_CLK_ENABLE();

   __HAL_RCC_USB_OTG_HS_ULPI_CLK_ENABLE();

   /* Peripheral interrupt init */

   HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0);

   HAL_NVIC_EnableIRQ(OTG_HS_IRQn);

 /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */

 /* USER CODE END USB_OTG_HS_MspInit 1 */

 }

}

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 = 6;

 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 = DISABLE;

 hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;

 hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;

 hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;

 if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)

 {

   _Error_Handler(__FILE__, __LINE__);

 }

 HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);

 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);

 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);

 }

 if (pdev->id == DEVICE_HS) {

 /* Link the driver to the stack. */

 hpcd_USB_OTG_HS.pData = pdev;

 pdev->pData = &hpcd_USB_OTG_HS;

 hpcd_USB_OTG_HS.Instance = USB_OTG_HS;

 hpcd_USB_OTG_HS.Init.dev_endpoints = 8;

 hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_FULL; // Changing to PCD_SPEED_HUGH does not help

 hpcd_USB_OTG_HS.Init.dma_enable = DISABLE;

 hpcd_USB_OTG_HS.Init.ep0_mps = DEP0CTL_MPS_64;

 hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_ULPI_PHY;

 hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE;

 hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE;

 hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE;

 hpcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE;

 hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE;

 hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE;

 if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK)

 {

   _Error_Handler(__FILE__, __LINE__);

 }

 HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);

 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80);

 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x174);

 }

 return USBD_OK;

}

0 REPLIES 0