Missing HAL_PWREx_EnableVddUSB when generating peripheral initialization as a pair of '.c/.h' files
Dear
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.
