Skip to main content
ACapo.1
Associate III
March 14, 2023
Solved

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

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

This topic has been closed for replies.
ACapo.1
ACapo.1Best answer
Associate III
March 15, 2023

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

1 reply

ACapo.1
ACapo.1AuthorBest answer
Associate III
March 15, 2023

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