This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Tiva USB HID Device Init problem

Hi,

I’ve ported my CCS project from a Stellaris M3 controller to the new Tiva TM4C124GH6PZ.

I used as a reference, the application report “Migrating Software Projects from StellarisWare to TivaWare”

So far the port has been successful, accept for the Tivaware USB Library - HID Device Class Driver.

In the original Stellaris code, we followed the example in the “Stellaris USB Library User’s Guide” to define our tUSBDHIDDevice. This worked.

To port the code I followed the Tiva migration instructions, removing the pointer to the private instance data in the tUSBDHIDDevice setup.

The new Tiva project builds without errors, however the processor goes in to the FaultISR() when the USBDHIDInit() function is called.  The fault codes are: “Bus Fault Address Register Valid” and “Precise Data Bus Error”.

Stepping though in the debugger, it looks like it faults when a USB library function is trying to read the tUSBDHIDDevice.ppsConfigDescripter.

I’m not sure what I am missing.

See code below:

static tUSBDHIDDevice g_sHIDTorqueDevice;

 bool HID::Init(unsigned int ProductId, unsigned int serialNumber)

{

       g_sHIDTorqueDevice.ui16VID                             = USB_VID_TI_1CBE;

       g_sHIDTorqueDevice.ui16PID                             = ProductId;

       g_sHIDTorqueDevice.ui16MaxPowermA               = 500;

       g_sHIDTorqueDevice.ui8PwrAttributes                    = USB_CONF_ATTR_SELF_PWR;

       g_sHIDTorqueDevice.ui8Subclass                         = USB_HID_SCLASS_NONE;

       g_sHIDTorqueDevice.ui8Protocol                         = USB_HID_PROTOCOL_NONE;

       g_sHIDTorqueDevice.ui8NumInputReports           = 1;

       g_sHIDTorqueDevice.psReportIdle                        = g_psReportIdle;

       g_sHIDTorqueDevice.pfnRxCallback                = _RxHandler;

       g_sHIDTorqueDevice.pvRxCBData                          = this;

       g_sHIDTorqueDevice.pfnTxCallback                = _TxHandler;

       g_sHIDTorqueDevice.pvTxCBData                          = this;

       g_sHIDTorqueDevice.bUseOutEndpoint              = true;

       g_sHIDTorqueDevice.psHIDDescriptor              = &g_sMouseHIDDescriptor;

       g_sHIDTorqueDevice.ppui8ClassDescriptors = g_pMouseClassDescriptors;

       g_sHIDTorqueDevice.ppui8StringDescriptors = g_pStringDescriptors;

       g_sHIDTorqueDevice.ui32NumStringDescriptors     = NUM_STRING_DESCRIPTORS;

       pvInstance = USBDHIDInit(0, &g_sHIDTorqueDevice);

       return(pvInstance != 0);

}

  • Hi,

    I'm struggling with the exact same problem. That's what I found out so far from stepping through the code:

    • I'm calling USBDHIDInit with a struct similiar to yours.
    • From there, USBDHIDCompositeInit is called with the same parameters basically.
    • USBDHIDCompositeInit initializes the private data and then calls USBDCDConfigGetInterfaceEndpoint, passing psHIDDevice->ppsConfigDescriptor[0] (which is a field in the tUSBDHIDDevice struct which never was initialized by us) to it.
    • This in turn calles USBDCDConfigGetInterface with the same parameters.
    • ...which is just a wrapper around USBDCDConfigDescGet in this case.
    • This then reads psConfig->psSections[0]->pui8Data which never was initialized, and causes the FaultInterrupt.

    To make matters worse, the example in the documentation doesn't set this parameter either (page 85, 2.13.2 Using the HID Device Class Driver). And in the documentation for the tUSBDHIDDevice type (page 94, 2.14.2.5), ppsConfigDescriptor is the only member with no documentation at all.

    From reading the source code for the keyboard/mouse HID libaries (usblib/device/usbdkeykeyb.c and usblib/device/usbhidmouse.c in TivaWare)  it seems you need to pass some kind of config descriptor (as opposed to a string descriptor) there, and indeed there's some documentation about that on page 155, under 2.23.1.2 tDeviceInfo.ppui8ConfigDescriptors.

    Did you find out more so far? I'm currently reading about how to create a proper config descriptor for my device - but I think this is definitely either a bug in the library (if a config descriptor should be optional) or in all the documentation.

  • I finally got an USB device to work by copying most of the config descriptor stuff from usbhidmouse.c.

    You can find the code I used pasted here.

    But TI should really mention this in their documentation, this is horrible...

  • Ran into same problem today. Wasted half of the day :( Thanks Florian Bruhin for sharing your code. It worked for me. Thumb down TI.