Skip to main content
Associate III
August 19, 2025
Question

Error messages: "'USBWakeUp_IRQn' undeclared"

  • August 19, 2025
  • 3 replies
  • 538 views

Hello all

I'm trying to use the HAL library for STM32U5G9 and have encountered errors in the code, which I don't know how to solve

 

Description Resource Path Location Type
'PCD_SNG_BUF' undeclared (first use in this function) usbd_conf.c /usb_hal/Middleware/ST/USB_DEVICE/Target line 447 C/C++ Problem
'USB_LP_IRQn' undeclared (first use in this function) usbd_conf.c /usb_hal/Middleware/ST/USB_DEVICE/Target line 87 C/C++ Problem
'USB_LP_IRQn' undeclared (first use in this function) usbd_conf.c /usb_hal/Middleware/ST/USB_DEVICE/Target line 117 C/C++ Problem
'USBWakeUp_IRQn' undeclared (first use in this function) usbd_conf.c /usb_hal/Middleware/ST/USB_DEVICE/Target line 93 C/C++ Problem
'USBWakeUp_IRQn' undeclared (first use in this function) usbd_conf.c /usb_hal/Middleware/ST/USB_DEVICE/Target line 119 C/C++ Problem

and these are the relevant lines 

 

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData, 0x00, PCD_SNG_BUF, 0x0C);
/////////////////////////////////////////////////
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
 if(pcdHandle->Instance==USB)
 {
 /* USER CODE BEGIN USB_MspInit 0 */

 /* USER CODE END USB_MspInit 0 */
 /* Peripheral clock enable */
 __HAL_RCC_USB_CLK_ENABLE();

 /* Peripheral interrupt init */
 HAL_NVIC_SetPriority(USB_LP_IRQn, 6, 0);
 HAL_NVIC_EnableIRQ(USB_LP_IRQn);
 if(pcdHandle->Init.low_power_enable == 1)
 {
 /* Enable EXTI Line 18 for USB wakeup */
 __HAL_USB_WAKEUP_EXTI_ENABLE_IT();
 HAL_NVIC_SetPriority(USBWakeUp_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(USBWakeUp_IRQn);
 }
 /* USER CODE BEGIN USB_MspInit 1 */

 /* USER CODE END USB_MspInit 1 */
 }
}
/////////////////////////////////////////////
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
 if(pcdHandle->Instance==USB)
 {
 /* USER CODE BEGIN USB_MspInit 0 */

 /* USER CODE END USB_MspInit 0 */
 /* Peripheral clock enable */
 __HAL_RCC_USB_CLK_ENABLE();

 /* Peripheral interrupt init */
 HAL_NVIC_SetPriority(USB_LP_IRQn, 6, 0);
 HAL_NVIC_EnableIRQ(USB_LP_IRQn);
 if(pcdHandle->Init.low_power_enable == 1)
 {
 /* Enable EXTI Line 18 for USB wakeup */
 __HAL_USB_WAKEUP_EXTI_ENABLE_IT();
 HAL_NVIC_SetPriority(USBWakeUp_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(USBWakeUp_IRQn);
 }
 /* USER CODE BEGIN USB_MspInit 1 */

 /* USER CODE END USB_MspInit 1 */
 }
}

 

I have even attached the C file.

Admittedly, I ported these files from the STM32CUBEG4, so it may not be compatible with u5, but surely modifications could be made to make it more accessible?

 

Kind regards

 

 

3 replies

TDK
Super User
August 19, 2025

The compiler says that PCD_SNG_BUF is not defined. Is it? Where? Ensure it is defined prior to being used. Use Search -> File... from the menu to see where it exists within the project files.

It's not defined anywhere in the C file you attached.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Maaz1Author
Associate III
August 20, 2025

Hi

It was defined in some other header file as 0U, and the code has been amended to reflect that

Tesla DeLorean
Guru
August 19, 2025

Check stm32u5xx_hal_conf.h as to what's being pulled in.

Check command line defines passed to the compiler, the part designation for sure.

Make sure the IRQ Handlers and enumerations are consistent between the STM32 models. Check naming in startup.s and enumerations for STM32U5G9 specifically.

Find-in-Files, or grep for : USBWakeUp_IRQn  USB_LP_IRQn, etc

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Maaz1Author
Associate III
August 20, 2025

Hi, this is the part I'm struggling with currently. The comments say 

 

/* Enable EXTI Line 18 for USB wakeup */
 __HAL_USB_WAKEUP_EXTI_ENABLE_IT();
 HAL_NVIC_SetPriority(USBWakeUp_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(USBWakeUp_IRQn);

 

but I'm not sure that the stm32u5g9 has that same configuration as well

Maaz1_0-1755680297179.png


or rather, I don't know how to read this 

STM32U5 series Arm<Sup>®</Sup>-based 32-bit MCUs - Reference manual


I've attached the reference manual for use

 

TDK
Super User
August 20, 2025

Are there U5 examples you could start from instead? Yes, quite a few things will be different between those two chips.

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