cancel
Showing results for 
Search instead for 
Did you mean: 

Does the USB as a mass storage device enter a sleep state? if so, how do i prevent this?

MStea.1
Associate II

The ADCs I'm logging data from occasionally shut off and then come back on and start streaming data. When this happens, the USB seems to have entered a sleep state as the write time for the packet header goes from taking ~20 milliseconds to taking upwards of 2 whole seconds sometimes more.

I made a "keepAlive" function that writes data to the USB flash drive and resets the file pointer back to the beginning as a way to keep pushing data to it. With this I've gotten rid of the crazy random 2 second plus write times when the ADCs come back on.

This is such a caveman solution. Does anyone know how to keep this "sleep" mode from happening or how to pre-wake it before I need to write data?

3 REPLIES 3
Pavel A.
Evangelist III

USB devices should implement selective suspend. The host can be told to NOT use selective suspend, but the device nevertheless should expect that it may be used.

Storage devices do not stream data to the host on their own, so when the host activates suspend, the device just notices it and keeps its internal operations.

When the host resumes reading, the device can send its data.

MStea.1
Associate II

Do you now how to tell the host NOT to use selective suspend in CUBE or in the usb host .c/.h file?

Which STM32?

Is the STM32 here host or device?

JW