cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0B1RE USB_DRD_FS

sravani
Associate III

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 

34 REPLIES 34
AScha.3
Chief II

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 "Accept as Solution".

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 */

 

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

If you feel a post has answered your question, please click "Accept as Solution".

i get error: USB not recognized

Can you show i pic of the build - esp. the usb connection ?

If you feel a post has answered your question, please click "Accept as Solution".

WhatsApp Image 2024-07-12 at 2.28.30 PM.jpegWhatsApp Image 2024-07-12 at 2.28.30 PM (1).jpeg

Might work. 🙂

Sure about (2x green wire) DP+/- ? If puzzeled, it never works.

+

In Cube , setup: have you usb- PD enabled ? Disable, if you did.

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

Am not getting GPIO pins

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