cancel
Showing results for 
Search instead for 
Did you mean: 

STMCubeIDE STM32u5a9j-dk, generated code does not bring up USB when set to device.

ACapo.1
Senior

Hi Guys,

In STM32CubeIDE I start a new project for this board, I leave everything in the ioc unchanged and generate the code.

The call to MX_USB_OTG_HS_HCD_Init() works correctly.

I now change in the ioc: USB_OTG_HS Internal HS Phy from host_only to device_only and regenerate the code.

Now the call to MX_USB_OTG_HS_PCD_Init() ends up in the Error_Handler(), this is caused by a timeout in USB_CoreReset().

Does anyone have any ideas why this might be?

Many thanks

Andy

1 ACCEPTED SOLUTION

Accepted Solutions
ACapo.1
Senior

Just incase anyone else is experiencing this I have stumbled on a workaround.

I used the clock generator to set to 160mhz, set SDMMC mux to clk48 and set OTG HS mux to HSE.

I then added __HAL_RCC_SYSCFG_CLK_ENABLE() to HAL_MspInit() :

void HAL_MspInit(void)
{
  /* USER CODE BEGIN MspInit 0 */
  __HAL_RCC_SYSCFG_CLK_ENABLE();
  /* USER CODE END MspInit 0 */
 
  __HAL_RCC_PWR_CLK_ENABLE();
 
  /* System interrupt init*/
 
  /* USER CODE BEGIN MspInit 1 */
 
  /* USER CODE END MspInit 1 */
}

I couldn't get it to work with the default clock setup

View solution in original post

1 REPLY 1
ACapo.1
Senior

Just incase anyone else is experiencing this I have stumbled on a workaround.

I used the clock generator to set to 160mhz, set SDMMC mux to clk48 and set OTG HS mux to HSE.

I then added __HAL_RCC_SYSCFG_CLK_ENABLE() to HAL_MspInit() :

void HAL_MspInit(void)
{
  /* USER CODE BEGIN MspInit 0 */
  __HAL_RCC_SYSCFG_CLK_ENABLE();
  /* USER CODE END MspInit 0 */
 
  __HAL_RCC_PWR_CLK_ENABLE();
 
  /* System interrupt init*/
 
  /* USER CODE BEGIN MspInit 1 */
 
  /* USER CODE END MspInit 1 */
}

I couldn't get it to work with the default clock setup