LPC4088 USBD USB Device sometimes fails to enumerate

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by Blackclaws on Fri Aug 07 04:30:06 MST 2015
So I have a rather peculiar problem that appears irregularly but proves to be rather problematic.

I am developing an application that uses the USBD ROM library to connect to a computer. Usually this works without any problems but sometimes the LPC4088 USB device seems to fall into a fail state that makes it impossible to enumerate the device no matter on which computer, which OS (windows or linux) and no matter which example is run (own application, usbd examples) which ran fine before.

This state appears irregularly and seems to persist for quite a while, through multiple reflashs of the firmware, multiple power cycles of the device and multiple times grounding the device.

It then magically disappears somehow only to reappear at some later date.  This is obviously completely ridiculous for production level software or a finished product. I have not been able to trace the root of this problem so I'm asking here for advice now. The error I receive from my OS is that the endpoint is stalled during the get device descriptor call.

I have so far excluded that the cable is at fault as I have changed that cable and the problem persists, as well as the cable not being touched and the problem suddenly appearing.

I have tried resetting the USB peripheral using:

USBD_API->hw->ResetEP(g_hUsb, 0);
USBD_API->hw->ResetEP(g_hUsb, 0x80);

However that didn't change anything. The problem exists since I started playing with the USB device peripheral and does not only exist for USBD ROM code but also for code using manual access to the USB peripheral.

Any further ideas as to what could cause this behavior and how to fix it would be greatly appreciated. If you believe that it is indeed a hardware fault with my board please tell me how I would be able to detect whether that is the case.