cancel
Showing results for 
Search instead for 
Did you mean: 

Missing HAL_PWREx_EnableVddUSB when generating peripheral initialization as a pair of '.c/.h' files

ego
Associate II

Dear @KDJEM.1 ,

I have seen that in STM32CubeIDE Version: 1.16.0 this issue is solved if the "Generate peripheral inizialization as a pair of '.c/.h' files per peripheral" is NOT selected in the ".ioc". Otherwise, the problem keeps there and "HAL_PWREx_EnableVddUSB()" is not called.

Here, you can see the code if the option is NOT selected:

 

 

 

 

void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
{
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
  if(hpcd->Instance==USB_DRD_FS)
  {
  /* USER CODE BEGIN USB_DRD_FS_MspInit 0 */

  /* USER CODE END USB_DRD_FS_MspInit 0 */

  /** Initializes the peripherals clock
  */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
    PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
    {
      Error_Handler();
    }

  /* Enable VDDUSB */
  HAL_PWREx_EnableVddUSB();
    /* Peripheral clock enable */
    __HAL_RCC_USB_CLK_ENABLE();
    /* USB_DRD_FS interrupt Init */
    HAL_NVIC_SetPriority(USB_DRD_FS_IRQn, 6, 0);
    HAL_NVIC_EnableIRQ(USB_DRD_FS_IRQn);
  /* USER CODE BEGIN USB_DRD_FS_MspInit 1 */

  /* USER CODE END USB_DRD_FS_MspInit 1 */

  }

}

 

 

 

And here if the option is selected:

 

 

 

void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
{

  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {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 clock
  */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
    PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
    {
      Error_Handler();
    }

    /* USB_DRD_FS clock enable */
    __HAL_RCC_USB_CLK_ENABLE();

    /* USB_DRD_FS interrupt Init */
    HAL_NVIC_SetPriority(USB_DRD_FS_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(USB_DRD_FS_IRQn);
  /* USER CODE BEGIN USB_DRD_FS_MspInit 1 */

  /* USER CODE END USB_DRD_FS_MspInit 1 */
  }
}

 

 

 

As you can observe, in the second case, the function is missing.

Could you please check that?

In my case, the selected uC is STM32H563ZIT6.

Thank you and regards.

Egoitz.

2 REPLIES 2
KDJEM.1
ST Employee

Hello @ego ,

 

This post is moved from Solved: Re: STM32H573 USBX CDC ACM(DEVICE) - STMicroelectronics Community.

Thank you for bringing this issue to our attention.

I confirm the issue HAL_PWREx_EnableVddUSB() function call is not generated at any source code in the project when generating code by choosing "Generate peripheral initialization as a pair of '.c/.h' files per peripheral" 

I reported this issue internally.

Internal ticket number: 190972 (This is an internal tracking number and is not accessible or usable by customers).

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Great, thank you Kaouthar!

Best regards.