Skip to main content
Visitor II
August 5, 2020
Question

Nucleo STM32F413ZH USB code 43

  • August 5, 2020
  • 4 replies
  • 1039 views

Hi

This is my first experience on a stm32 Nucleo F413ZH

I am trying to make it a game device (USB HID), followed some tutorials and slowly getting there.

There is just one thing that doesn't come clear to me.

The compiler doesn't give me any error, but the USB device popping up gives me a code 43.

I would highly appreciate some pointers or what the solution could be.

Maybe my info is falling short,please ask me what you need more to come to the solution.

Thanks in advance.

    This topic has been closed for replies.

    4 replies

    MHovi.1Author
    Visitor II
    August 6, 2020

    Nobody?

    Super User
    August 6, 2020

    Code 34 means "Windows has stopped this device because it has reported problems".

    This means, after successful enumeration, the device acted up and the USB bus driver decided to kill it.

    Debugger and USB bus analyzer (sniffer) are your friends.

    If you use code published by other people, you can also ask them to help to reproduce their results.

    -- pa

    MHovi.1Author
    Visitor II
    August 9, 2020

    Hi Pavel

    Thanks for the advice.

    I managed to get it recognized by the host, in the USBD_config.h the out report buffer size was set wrong (USBD_CUSTOMHID_OUTREPORT_BUF_SIZE)

    I had to set the number of bytes used by the Usb HID report descriptor.

    Firstly i gave up, but i couldn't resit to start reading about usb mechanics. I came across this website https://www.beyondlogic.org/usbnutshell/usb1.shtml.

    It gave me a better insight how usb protocols work.

    My device only shows up as game device atm, now i need to setup my buttons and other stuff.

    MHovi.1Author
    Visitor II
    August 15, 2020

    Another Question if i may,

    I have this custom HID report descriptor

    0x05, 0x01, // USAGE_PAGE (Generic Desktop)
    		 0x15, 0x00, // LOGICAL_MINIMUM (0)
    		 0x09, 0x05, // USAGE (Game Pad)
    		 0xa1, 0x01, // COLLECTION (Application)
    		 0x05, 0x05, // USAGE_PAGE (Gaming Controls)
    		 0x0b, 0xbb, 0x00, 0x02, 0x00, // USAGE (Simulation Controls:Throttle)
    		 0x15, 0x81, // LOGICAL_MINIMUM (-127)
    		 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
    		 0x75, 0x08, // REPORT_SIZE (8)
    		 0x95, 0x01, // REPORT_COUNT (1)
    		 0x81, 0x02, // INPUT (Data,Var,Abs)
    		 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
    		 0x09, 0x01, // USAGE (Pointer)
    		 0xa1, 0x00, // COLLECTION (Physical)
    		 0x09, 0x30, // USAGE (X)
    		 0x09, 0x31, // USAGE (Y)
    		 0x95, 0x02, // REPORT_COUNT (2)
    		 0x81, 0x02, // INPUT (Data,Var,Abs)
    		 0xc0, // END_COLLECTION
    		 0x09, 0x39, // USAGE (Hat switch)
    		 0x15, 0x00, // LOGICAL_MINIMUM (0)
    		 0x25, 0x03, // LOGICAL_MAXIMUM (3)
    		 0x35, 0x00, // PHYSICAL_MINIMUM (0)
    		 0x46, 0x0e, 0x01, // PHYSICAL_MAXIMUM (270)
    		 0x65, 0x14, // UNIT (Eng Rot:Angular Pos)
    		 0x75, 0x04, // REPORT_SIZE (4)
    		 0x95, 0x01, // REPORT_COUNT (1)
    		 0x81, 0x02, // INPUT (Data,Var,Abs)
    		 0x05, 0x09, // USAGE_PAGE (Button)
    		 0x19, 0x01, // USAGE_MINIMUM (Button 1)
    		 0x29, 0x03, // USAGE_MAXIMUM (Button 8)
    		 0x15, 0x00, // LOGICAL_MINIMUM (0)
    		 0x25, 0x01, // LOGICAL_MAXIMUM (1)
    		 0x75, 0x01, // REPORT_SIZE (1)
    		 0x95, 0x04, // REPORT_COUNT (8)
    		 0x55, 0x00, // UNIT_EXPONENT (0)
    		 0x65, 0x00, // UNIT (None)
    		 0x81, 0x02, // INPUT (Data,Var,Abs)

    In the button part i want to set it to 32 buttons if i increase the report count value bigger as 0x04 i get a code 10 meaning report descriptor is not 4-byte aligned.

    I read upon it and have a small understanding of what is meant by it, but for now i have no clue where to tackle this.

    Suggestions are welcome.

    Oh and the usage maximum wont exceed 4 meaning the maximum buttons in windows is 4 but when decreased to for example 3 , windows shows 3 buttons.

    But it looks like it related to the report count byte alignment issue.