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.

USBHMSCDriveReady() can take extremely long time to execute

I spent quite a bit of time yesterday trying to get my code to recognize a USB stick. Every time I plugged it in, my code would go crazy, going into a continual reset mode where breakpoints would not work. I finally discovered that the call to USBHMSCDriveReady() in my OTG polling loop was taking nearly 1.4 seconds to execute. Since I have the watchdog timer configured to reset the system after 500 ms, the code would never get a chance to return from the call to USBHMSCDriveReady().

Now that I know what is going on, I have resolved the problem by disabling the watchdog during the call. But I wanted to share my discovery in case others may experience similar problems in the future.

Also, there is no mention in the USB Library User's Guide regarding the large amount of time this function can remain captive. Seems like it would be a good idea to add a note in the documentation that it can take a long time for the function to return. I imagine it probably depends on the type of drive plugged in.

Regards,

Dave