Skip to main content
Visitor II
March 30, 2023
Solved

STM32G0B USB error during initialization, SOLVED by modifying your library

  • March 30, 2023
  • 2 replies
  • 1230 views

in usb library in the file generated by STM32CubeMx for the STM32G0B1

 * @file          : Target/usbd_conf.c

 * @version       : v3.0_Cube

 * @brief         : This file implements the board support package for the USB device library

in function void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)

line 205 you have the test

 if (( hpcd->Init.speed != USB_DRD_SPEED_FS) ) || (hpcd->Init.speed != USB_DRD_SPEED_LS))

 {

   Error_Handler();

 }

this is obviously always true, and you always go to Error_Handler

I modified the test

 if (( hpcd->Init.speed != USB_DRD_SPEED_FS) ))

 {

   Error_Handler();

 }

now it's running.

Please can you check your library and give me a better solution, I don't like to modify manufacturer library.

    This topic has been closed for replies.
    Best answer by KDJEM.1

    Hello @GPREV.1​ and welcome to the Community :) ,

    I have tried to reproduce this error but I didn't find any issue when I build the project with STM32CubeIDE 1.12.0, STM32CubeMx6.8.0 and STM32Cube_FW_G0_V1.6.1.

    The code is well described in usbd_conf.c file

     if (hpcd->Init.speed != USBD_FS_SPEED)
     {
     Error_Handler();
     }

    Could you please try to use the last firmware version of STM32CubeG0 and le last M32CubeMX.6.8.0 version.

    Please let me know if the problem is solved.

    When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

    Thank you.

    Kaouthar

    2 replies

    KDJEM.1Answer
    Technical Moderator
    March 31, 2023

    Hello @GPREV.1​ and welcome to the Community :) ,

    I have tried to reproduce this error but I didn't find any issue when I build the project with STM32CubeIDE 1.12.0, STM32CubeMx6.8.0 and STM32Cube_FW_G0_V1.6.1.

    The code is well described in usbd_conf.c file

     if (hpcd->Init.speed != USBD_FS_SPEED)
     {
     Error_Handler();
     }

    Could you please try to use the last firmware version of STM32CubeG0 and le last M32CubeMX.6.8.0 version.

    Please let me know if the problem is solved.

    When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

    Thank you.

    Kaouthar

    GPREV.1Author
    Visitor II
    March 31, 2023

    M32CubeMX 6.8.0 solves this problem.

    Just a remark on the new usbd_conf.c file.

    There are some code changes but the header is the same as the old bad version.