Skip to main content
Associate
Jul 15, 2025 5:54 AM UTC
Question

STM32H523 USBX Standalone HID Device Crashes on ux_slave_dcd_function

I am building a device using a STM32H523RET6 microcontroller on a custom board (self-powered, with VBUS detection). My eventual goal is to operate a USB-CDC interface between the board and a computer for telemetry, but since the only standalone USB example I could find in the STM32CubeH5 examples was HID, I am trying to get a HID interface working first. I do not want to use the RTOS for my device. I have attempted to adapt the code from this example, https://github.com/STMicroelectronics/STM32CubeH5/tree/main/Projects/NUCLEO-H563ZI/Applications/USBX/Ux_Device_HID_Standalone to the H523 device, but the program crashes in the function _ux_device_stack_tasks_run when the function ux_slave_dcd_function is called. As you can see from the stack trace, this is called from the USBX_Device_Process() function which is periodically called. I have been unable to find any detailed information or examples pertaining to USB on the H523 device, so any information or pointers would be amazing.

nifley_0-1752558462510.png

nifley_1-1752558707376.png

I haven't changed the USBX configuration from the default aside from selecting these options.

Thanks, FB.

 

This topic has been closed for replies.

3 replies

MOBEJ
ST Employee
Jul 15, 2025 8:25 AM UTC

Hello @nifley ,

Please take a look at this article: "How to implement a USB device composite in STM32H5 microcontrollers". It provides a detailed guide that can help you configure your project using STM32CubeMX .

Br

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.
nifleyAuthor
Associate
Jul 15, 2025 5:31 PM UTC

Thanks for pointing me to that example - I don't know how I didn't find that earlier! I have adapted that example to my board; it seems that the USB device initializes, but unfortunately, my computer says that it does not recognize the device. 

nifley_0-1752599624071.png

nifley_3-1752600163891.png

 

Looking at other solutions to this problem, I have added

HAL_PWREx_EnableUSBVoltageDetector();
if (HAL_GPIO_ReadPin(VBUS_SENS_GPIO_Port, VBUS_SENS_Pin)) {
 HAL_PWREx_EnableVddUSB();
 usb_connected = true;
}

 To my initialization code, but it seems to have no effect. I'm pretty sure I have the USB lines wired properly, but I could be wrong. 

nifley_1-1752599775496.png

nifley_2-1752600012547.png

 

 

ST Technical Moderator
Aug 6, 2025 1:44 PM UTC

Hi @nifley 

Do you reproduce the issue using reference board for example NUCLEO-H533RE?

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