Skip to main content
Visitor II
April 13, 2024
Solved

STM32U595ZJT6Q USB not initializing

  • April 13, 2024
  • 1 reply
  • 2233 views

I'm trying to work with USB on STM32U595ZJT6Q (with SMPS)

Ref Clock Selection under USB_OTG_HS is set to 16MHz
OTS HS Clock Mux is set to HSE (the board has 16MHz crystal)

CubeMX 6.11
STM32Cube_FW_U5_V1.5.0

The code is stuck in USB_CoreReset, more specifically it waits for USB_OTG_GRSTCTL_CSRST to become 0

 

 do
 {
 count++;

 if (count > HAL_USB_TIMEOUT)
 {
 return HAL_TIMEOUT;
 }
 } while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST);

 

After searching the forum I discovered that CubeMX is not generating __HAL_RCC_SYSCFG_CLK_ENABLE call in HAL_PCD_MspInit. However, after adding this call nothing changes.

 

void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
{

 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
 if(pcdHandle->Instance==USB_OTG_HS)
 {
 /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */
 __HAL_RCC_SYSCFG_CLK_ENABLE();
 /* USER CODE END USB_OTG_HS_MspInit 0 */

 

Can someone help me resolve the issue?

    This topic has been closed for replies.
    Best answer by SYako

    Okay, I think I figured it out. SYSCLK has to be more than 48MHz. Just changing it to 64 MHz fixed an issue.

    1 reply

    Super User
    April 13, 2024

    Do you set the USB clock to 48Mhz ?

    I don't understand what you wrote.

    SYakoAuthor
    Visitor II
    April 13, 2024

    It's not even possible to set 48MHz with U5 seriesUntitled.png

    Super User
    April 13, 2024

    Ok, sorry - 48M is mandatory for full speed , but you set it to hi speed . So ok , but i wouldn't choose the lowest clk.

    btw

    I found in similar H5 USB setting : the power enable was missing - so check, if this is there.

    I added in xxx_hal_msp.c :

    in 

    void HAL_HCD_MspInit(HCD_HandleTypeDef* hhcd)

     /* USER CODE BEGIN USB_DRD_FS_MspInit 1 */
     HAL_PWREx_EnableVddUSB();
     /* USER CODE END USB_DRD_FS_MspInit 1 */