cancel
Showing results for 
Search instead for 
Did you mean: 

HID communication with classic USB library on STM32U5

Simo_Sappo
Associate III

Hi everyone, I am trying to implement HID communication using the classic USB library on the NUCLEO-U5A5ZJ-Q. Until now I tried to follow this tutorial 

https://community.st.com/t5/stm32-mcus/how-to-use-stmicroelectronics-classic-usb-device-middleware-with/ta-p/599274

Sadly, between the H7 and U5 there are a couple of difference and I can't seem to find a way to make use of this tutorial for it.

I tried to implement the HID Device from this git 

https://github.com/STMicroelectronics/stm32u5-classic-coremw-apps/tree/main/Projects/NUCLEO-U575ZI-Q/Applications/USB_Device/HID_Standalone

but I am not able to merge these file within an STM32CubeIDE project and make it work (I didn't even manage to build it).

Before getting into the USBX version of the HID communication I still want to try to implement one without the use of a FreeRTOS, can somebody help me? Maybe if you already followed one of the links you can tell me what extra steps you did to make it work. Thank you in advance!

2 REPLIES 2
mhupp
Associate

Hello Simo_Sappo,

you didn't provide much information about the type of your HID project, so I can't offer a concrete way to build your project at the moment. Are you planning a project based on the standard HID class or do you want to develop a custom HID device ?

For start a short step-by-step guide on how to integrate your classic middleware.
Start a new STM32 project and create an empty framework with the Cube IDE.

- File -> New -> STM32 Project
- Enter the Commercial Part Number STM32U575ZIT6Q into the MCU/MPU Selector
- Click on the MCU/MPU list showing the NUCLEO-U575 Board and click Next
- Enter the Project Name and the Project location into the Dialog Box and press Finish
- The IDE should show now the CubeMX view
- Select System Core -> SYS -Timebase Source -> SysTick
- Select -> Connectivity -> USB_OTG_FS --> Mode -> Device Only and NVIC enable Inter
- Select -> RCC -> CRS SYNC -> CRS SYNC Source USB
- Change to the Clock Configuration
- PLL1 Input HSI , PLLM = 1, N = 10, R= 1, Sys Mux to PLL -> HCLK 160MHz
From the previous setting you should see USB Clock = 48MHz
Press save and let the IDE generate the Project Framework, skip the ICACHE for now.
Now you should have the Start FrameWork , Build the Project. -> No Errors

Now copy the legacy Middleware under the Driver directory and press Refresh the project tree. You should see that the middleware becomes part of you project tree.

For the next step you provide some info  what type of HID device you want to build.

Hey thank you for the reply, Yes I am trying to build a Custom HID device. Your instruction are pretty clear but sadly I cannot follow them:

Screenshot 2024-11-28 123923.png

  first, the only option available is USB_OTG_HS, 

Screenshot 2024-11-28 124253.png

 second, the CRS SYNC Source USB does not show up and if don't use an external oscillator the USB is not available at all.

 

Screenshot 2024-11-28 124413.png

 and last but not the least, if I try to setup the clock with values different from 16,20,24,26 and 32 Mhz I get this error (why this happens is documented in RM0456 but I don't know what should I do)

 

Also the board I am working on is the NUCLEO-U5A5ZJ-Q not U575