Jump to content

Why can't my USB HID device start in Windows?


Recommended Posts

I'm trying to fix an error This device cannot start. (Code 10) with a USB HID device I'm building. Here are some details on my project:


MCU: PIC32MX250F128B(http://www.kynix.com/Detail/506908/PIC32MX250F128B-50I%2FML.html)
Programmer: Microstick II
Git Repository: https://github.com/josefvanniekerk/pic32_usb

Please refer to the code above, it's not big, I'm trying not to flood the question with source code


The device enumerates, and I'm able to see that Windows 7 and Mac OS X is able to identify the device.



However in Windows, I'm getting an error: This device cannot start. (Code 10)



I've been trying to fix this for a while. After redoing my breadboard wiring last week to try and improve the signal quality, I've come, trying to alter my code to get things working.

I'm using USB_INTERRUPT mode, and have my descriptor looks as follows:


     0x12,                       // Descriptor size in bytes 
     USB_DESCRIPTOR_DEVICE,      // Device descriptor type 
     0x0200,                     // USB spec release number in BCD format 
     0x00,                       // Class code 
     0x00,                       // Subclass code 
     0x00,                       // Protocol code 
     USB_EP0_BUFF_SIZE,          // Max packet size for EP0 
     MY_VID,                     // Vendor ID 
     MY_PID,                     // Product ID 
     0x0001,                     // Device release number in BCD format 
     0x01,                       // Manufacturer string index 
     0x02,                       // Product string index 
     0x00,                       // Device serial number string index 
     0x01                        // Number of possible configurations 


and the HID report discriptor, (built with HID Tool from usb.com):

ROM struct{BYTE report[HID_RPT01_SIZE];} hid_rpt01 =
        0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
        0x09, 0x04,                    // USAGE (Joystick)
        0xa1, 0x01,                    // COLLECTION (Application)
        0x09, 0x04,                    //   USAGE (Joystick)
        0xa1, 0x00,                    //   COLLECTION (Physical)
        0x05, 0x09,                    //     USAGE_PAGE (Button)
        0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
        0x29, 0x08,                    //     USAGE_MAXIMUM (Button 8)
        0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
        0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
        0x95, 0x08,                    //     REPORT_COUNT (8)
        0x75, 0x01,                    //     REPORT_SIZE (1)
        0x81, 0x02,                    //     INPUT (Data,Var,Abs)
        0xc0,                          //     END_COLLECTION
        0xc0                           // END_COLLECTION

The above represents a Joystick with one button, so I'm trying to start small. My HID report looks like this:

     BYTE buttons;


I've also set the descriptor size to 28 bytes in usb_config.h:

#define HID_RPT01_SIZE 28

This is about the furthest I've come with this project ever, but I'm face to face with a brick wall, that won't budge. Any help would be much appreciated. The full contents of main.c is at my GitHub repository

I'm testing my device on both Mac and Windows 7 via VMWare. The Microstick II doesn't appear to have the best debugger, so debugging is limited.

What I've done is light up an LED on Pin 2 (RA0) when USBDeviceState == CONFIGURED_STATE, and all I know is that the device is in CONFIGURED_STATE, as the LED lights up a few moments after the device is plugged in. I also managed to get the following from the USBLizer trial version:


I can't set breakpoints in MPLABX, and halt the MCU to investigate the issue, because of USB clock timing requirements, so really stuck as to how I can troubleshoot and fix this.

For what it's worth, I've set a breakpoint for the EVENT_BUS_ERROR handler in main.c, and the following U1EIR registers' bits are set:

    *DFN8EF - Data Field Size Error Flag bit
    *CRC5EF_EOFE - CRC5 Host Error Flag bit
    *PIDEF - PID Check Failure Flag bit


Am I getting these errors because I'v entered debug mode and the chip isn't happy, and these aren't the actual errors at all, and if these errors are in fact correct indications of my problem, what does it mean?

If I'm getting a DFN8EF - Data Field Size Error Flag bit, how do I figure out what data field is the wrong size? It's likely to be my descriptor, or HID report, but I can't find the fault.


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
Back to top
  • Create New...

Important Information

This site uses cookies - We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.