cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 USB Device Custom HID example

VCapu
Associate III

I am using a custom board with STM32F4 micro and I want to use the Cube libraries. I need a simple example of application of a USB Device configured as Custom HID. I need to know not only how to configure the USB, but also how to transmit data to the PC. On the PC I have a working custom driver software. I really don't know where to start.... Thank you very much.

1 ACCEPTED SOLUTION

Accepted Solutions
VCapu
Associate III

Ok. Solved for now. It was an hardware problem (damaged board). I tried the keyboard and the custom HID example. Now I need to modify an example so I can communicate with my custom driver on PC. My custom board has to work as a customizable keyboard. Is it better to start from the keyboard example or the custom HID example? Any suggestion on which part of the code I need to modify? Thank you

View solution in original post

10 REPLIES 10
Petr DAVID
ST Employee

Hello VCapu,

If you are not sure where to start I would like to direct you to STM32 USB training. In the video material there is covered many topics on USB for and the lab are done on STM32F4 MCU. There are also included some examples on HID devices. Some other examples are also available in STM32CubeF4 software package. You were saying you were using custom board, if you will run in to some hardware related problem I would also consider to check this document AN4879. Let me know if you have any further questions.

VCapu
Associate III

Thank you for the advice. I followed step by step the example "USB Custom HID Device lab", but when I connect the board to the PC it is detected as "Unkonwn Device" and if I try to open the HID terminal, it is shown the message "Failed to open device". Any suggestion? I am stuck on this part of my project...

Petr DAVID
ST Employee

I will gladly try to help you, but I will need more information from you about your HW setup. For start what MCU are you using and are you using embedded pull-up or external one? Also how do you clock your USB peripheral? Are you using external high speed oscillator? If you are using MCU for which there will be ready to use example within the STM32CubeF4 FW package I would maybe recommend to try this example so you exclude HW related problems. I will wait for your answer.

VCapu
Associate III

Hello Petr. The MCU is STM32F405ZGT6. In the GPIO settings on Cube I selected no pull up and no pull down. This is the clock configuration.0693W00000AOZeJQAX.pngIn the  STM32CubeF4 package there are no examples for boards with the same MCU. What could be the most similar to the one that I am using?

In this phase, I need only to see that USB communication is working, and then understand how to modify an example to adjust it for my application. Thank you.

Petr DAVID
ST Employee

Hello VCapu,

according to RM0090, STM32F405xx/07xx and STM32F415xx/17xx all should be really similar together and from this reason I would go for examples in folder STM324xG_EVAL. There is also code for custom hid example. Do I understand it correctly that you have external pull-up resistor at the D+ line and external oscillator on your custom board?

VCapu
Associate III

No, there is not external pull_up. I tried to set the internal pull-up but nothing changed. I use external oscillator.

I will try to check that example. I need to make some modifications? Thank you.

VCapu
Associate III

I tried also to use external pull-up on both USB lines or only on D+ but nothing changes.

VCapu
Associate III

Do you have any suggestions? Thanks

VCapu
Associate III

Ok. Solved for now. It was an hardware problem (damaged board). I tried the keyboard and the custom HID example. Now I need to modify an example so I can communicate with my custom driver on PC. My custom board has to work as a customizable keyboard. Is it better to start from the keyboard example or the custom HID example? Any suggestion on which part of the code I need to modify? Thank you