Skip to main content
Visitor II
July 21, 2026
Question

STM32H5E5: Classic USB CDC library problem

  • July 21, 2026
  • 3 replies
  • 28 views

Hi, everyone,

I'm trying to implement USB CDC on an STM32H5E5 board using the classic USB device middleware.

 

I followed another community thread that provides the steps to do this: 


How to Use STMicroelectronics’ Classic USB Device Middleware with the New STM32 Families:

 

 

When compiling the code, I encountered some errors at this point in the library:

 

USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)

{

pdev->pData = &hpcd_USB_DRD_FS;

 

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x00 , PCD_SNG_BUF, 0x40);

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , 0x80 , PCD_SNG_BUF, 0x80);

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_IN_EP , PCD_SNG_BUF, 0xC0);

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_OUT_EP , PCD_SNG_BUF, 0x100);

HAL_PCDEx_PMAConfig((PCD_HandleTypeDef*)pdev->pData , CDC_CMD_EP , PCD_SNG_BUF, 0x140);

 

return USBD_OK;

}

The error messages are as follows 

Description    Resource    Path    Location    Type
'PCD_SNG_BUF' undeclared (first use in this function)    usbd_conf.c    /USB_VirtualCOM/USB/Core/Src    line 90    C/C++ issue
Implicit function declaration for ‘HAL_PCDEx_PMAConfig’; did you mean ‘HAL_PWREx_PVMConfig’? [-Wimplicit-function-declaration]    usbd_conf.c    /USB_VirtualCOM/USB/Core/Src    line 90    C/C++ issue

 

Has anyone else encountered this exact problem? How can I fix this?

 

Thanks for your help!

3 replies

ST Technical Moderator
July 21, 2026

Hi ​@MatheusNifocci 

PCD_SNG_BUF and HAL_PCDEx_PMAConfig() should come from the H5 PCD HAL headers/sources. Check if the project includes the correct stm32h5xx_hal_pcd.h/stm32h5xx_hal_pcd_ex.c, that your include paths point to the H5 driver package, and that the repository was cloned with submodules recursively.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
mƎALLEm
ST Technical Moderator
July 21, 2026

@MatheusNifocci welcome to the ST community,

USB related questions especially those focusing on software implementation need to be posted in STM32 MCUs Embedded software forum board. I moved it.

Thank you for your understanding

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
ST Technical Moderator
July 21, 2026

Hello ​@MatheusNifocci 
Add on what ​@FBL  said,
the STM32H5E5 uses USB OTG controller while other STM32H5 products like STM32H563 uses USB DRD controller.
So, they don’t use the same variables and instances names.
in your case, try to use those pieces of code they will help you

/* Private variables ---------------------------------------------------------*/

PCD_HandleTypeDef hpcd_USB_OTG_FS;


/* USER CODE BEGIN USB_OTG_FS_Init 2 */



HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, USBD_MAX_EP0_SIZE / 4);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, USBD_CDCACM_EPIN_FS_MPS / 4); HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 2, USBD_CDCACM_EPINCMD_FS_MPS / 4);
ux_dcd_stm32_initialize((ULONG)USB_OTG_FS, (ULONG)&hpcd_USB_OTG_FS);
/* USER CODE END USB_OTG_FS_Init 2 */

To understand more you can use any STM32 product USB CDC firmware example that uses USB OTG controller like this example
BR
Gyessine

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.