cancel
Showing results for 
Search instead for 
Did you mean: 

USB HID GamePad with STMF103 and CubeMX

embedonix
Associate III
Posted on May 26, 2015 at 04:35

Hi All,

I have generated code for a USB HID device, but it does not do anything, I mean my PC does not recognize anything. I have not changed anything in the code because I was assuming that it should at least get detected by the PC when I insert the USB cable.

I think the problem is with the DISC at PC11 or CNTRL on PC10 port/pins. I did not find any code generated by CubeMX in this regard.

I also want to have HID Descriptor according to

http://www.usb.org/developers/hidpage/

 but I don't know where to put this in the code.

Can you suggest me any fix/solution please?

Please let me know if you need more details. Thanks.

#usb #cubemx #stm32f
3 REPLIES 3
arnaud239955
Associate II
Posted on May 26, 2015 at 05:00

Hello,

My USB implementation works with USB pins in the state as generated by the CubeMX software (I think it is merely the reset state). The ST datasheet is not really clear (but may be I missed something...) since USB function is placed in the ''Additional functions'' column of the Pin definition table.

You can use the WireShark tool to spy what's happen on the USB line https://wiki.wireshark.org/CaptureSetup/USB . I do it using a Linux box and I works perfect. This is useful because it may happen many things on the line even at application level nothing happens.

Zirco

embedonix
Associate III
Posted on May 26, 2015 at 06:32

Thanks, I tried that usb spy but it seems nothing happens at all.

This is the steps I took to generate code (for STMF103RBT6)

  1. PINOUT tab:

  • from pinout tab, PD0, PD1 for 8MHz crystal
  • PA11, PA12 for USB_DM, USB_DP
  • PA0 as GPIO_EXTIO for button press (goal is a HID joystic with 1 button

2. CLOCK CONFIGURATION

  • 48MHZ for USB, 72MHZ for HCLK, 9 MHz for cortext system timer, and 72 for FCLK

3. CONFIGURATION

  • setup GPIO and NVIC (to generate function for button IRQ event)
  • Add USB_DEVICE in HID mode (I did not change any settings here)

And then I generated and flashed the code. Nothing happens. Am I supposed to make any changes in the generated code?

Again, There is no code for usb disconnect as far as I see in the code.

What can be wrong? I have added the CubeMX project file to this post if you need to see it.

Thanks.

________________

Attachments :

USB_HID.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzJy&d=%2Fa%2F0X0000000bL1%2FNeFxWv46Qvhzg51kA3hHoqOOgYC0yhywDyfvKCCdd9Y&asPdf=false
arnaud239955
Associate II
Posted on May 26, 2015 at 06:42

I tested various USB project examples of ST and in general devices enumerate immediately, without problems.

Use the ST Link or other JTAG/SW probe to debug. There are so many possible mistakes and miss-configurations that only a debug work can point out the issue.

Zirco