Skip to main content
Associate II
July 11, 2024
Question

STM32G0B1RE USB_DRD_FS

  • July 11, 2024
  • 34 replies
  • 7173 views

Hi everyone,

 

I am currently working on a project involving the STM32G0B1RE microcontroller and had encountered an issue while configuring the USB_DRD_FS (Dual Role Device Full Speed) in Device mode using STM32CubeIDE.

Here are the steps I followed:

  1. I selected the USB_DRD_FS peripheral and set it to Device mode.
  2. I configured the USB_Device in CDC (Communications Device Class) mode under Middleware.

After completing these configurations, I noticed that the GPIO pins associated with the USB_DRD_FS peripheral didn't appear in the generated code or usbd_conf.c

 

Best regards,

Sravani 

    This topic has been closed for replies.

    34 replies

    AScha.3
    Super User
    July 11, 2024

    Hi,

    did you look in usbd_conf.c   for :  HAL_xx_MspInit( ...) ?

    There it should be...

    If you feel a post has answered your question, please click on " Best Answer ".
    sravaniAuthor
    Associate II
    July 11, 2024

    Am not getting GPIO pins, I get below code inside of PCD_MSP_Init,

    RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
    if(pcdHandle->Instance==USB_DRD_FS)
    {
    /* USER CODE BEGIN USB_DRD_FS_MspInit 0 */

    /* USER CODE END USB_DRD_FS_MspInit 0 */

    /** Initializes the peripherals clocks
    */
    PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
    PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSE;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
    {
    Error_Handler();
    }

    /* Peripheral clock enable */
    __HAL_RCC_USB_CLK_ENABLE();

    /* Enable VDDUSB */
    if(__HAL_RCC_PWR_IS_CLK_DISABLED())
    {
    __HAL_RCC_PWR_CLK_ENABLE();
    HAL_PWREx_EnableVddUSB();
    __HAL_RCC_PWR_CLK_DISABLE();
    }
    else
    {
    HAL_PWREx_EnableVddUSB();
    }

    /* Peripheral interrupt init */
    HAL_NVIC_SetPriority(USB_UCPD1_2_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(USB_UCPD1_2_IRQn);
    /* USER CODE BEGIN USB_DRD_FS_MspInit 1 */

    /* USER CODE END USB_DRD_FS_MspInit 1 */

     

    AScha.3
    Super User
    July 11, 2024

    Can you compile the project - or what errors you get ?

    If you feel a post has answered your question, please click on " Best Answer ".
    Pavel A.
    July 12, 2024

    Am not getting GPIO pins

    The USB pins can be set up in yet another .c file (msp...) - check all generated .c files.

     

    sravaniAuthor
    Associate II
    July 12, 2024

    Checked in All .c files , couldn't generate  gpio pins of USB

    AScha.3
    Super User
    July 12, 2024

    But you set/enable USB in Cube ? see the pins...and pin settings ?

    (+ debug enabled... ! )

    AScha3_0-1720786160433.png

    +

    AScha3_1-1720786209025.png

     

    If you feel a post has answered your question, please click on " Best Answer ".