AnsweredAssumed Answered

USB Generic HID+MSD Composite enumeration problems

Question asked by TERRY COOKE on Dec 16, 2015

I have a strange USB enumeration problem with a MK22FN512. It took a long time but I got the USB to enumerate properly and working, but unfortunately it only works when I have USBlyzer running to see enumeration issues. If USBlyzer is closed the device will not enumerate properly and it will always times out with a USB_PRINTF("not find interface"); in the USB_Class_Hid_Event() function in usb_hid.c.

 

With USBlyzer open it does the following in hid1_application_callback, and properly enumerates:

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_HID_SET_IDLE_REQUEST

* attached is a USBlyzer capture file when it works.

 

With USBlyzer closed it does the following before timing out in hid1_application_callback:

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

USB_DEV_EVENT_ENUM_COMPLETE

USB_DEV_EVENT_BUS_RESET

and then times out at:

not find interface

 

 

A few things I have found is that is that with USBlyzer closed, it tries to set a configuration of 0 in:USB_Set_Configuration ()

static uint8_t USB_Set_Configuration (   uint32_t      handle,   uint8_t       config ) {   UNUSED_ARGUMENT(handle);    usbDsc1_CurrentConfiguration = (config - 1U);   return USB_OK; }

 

it calls this function with config = 0 which sets it to an invalid configuration.

 

If anyone can find anything wrong with my attached usbDsc1.c/.h I would appreciate the help. I am at a complete loss and do not understand where to look next.

Original Attachment has been moved to: USBcode.zip

Original Attachment has been moved to: Enumeration-works.ulz.zip

Outcomes