Strictly necessary cookies are on by default and cannot be turned off. Functional, Performance and Tracking/targeting/sharing cookies can be turned on below based on your preferences (this banner will remain available for you to accept cookies). You may change your cookie settings by deleting cookies from your browser. Then this banner will appear again. You can learn more details about cookies HERE.
Strictly necessary (always on)
Functional, Performance and Tracking/targeting/sharing (default off)
USB device not working after restarting the Windows 7 PC
Question: USB device not working after restarting the Windows 7 PC. Why?
Till Windows Vista RTm, all the USB devices attached to the PC undergoes a USB reset, when the OS resumes or restarts. This makes sure that the device enumerates once the PC is restarted or resumed. However, from Windows 7 onwards, this bus wide USB reset is disabled. This enables the devices connected to the PC to maintain device-specific states even after restarting the PC. This significantly decreases the time it takes for the USB devices to be available after system resume.
However, this feature of the OS may lead to malfunctioning of the device, if the device firmware is written in such a way that enumeration of USB is done outside the main while(1) loop. In this case, the device is never reset when the PC restarts and hence, the enumeration API is never executed again.
In the attached project, enumeration of the device is done in a conditional IF statement within the main while(1) loop by checking the 'bDeviceEnumerated' which is initialised to FALSE. Once the enumeration is complete, this flag is set to TRUE . Hence, control doesn't reach the enumeration API once device is enumerated.
The firmware is written to detect the PC restart condition. This is done by monitoring the SOF packets. On reception of every SOF packets, a counter 'bCtr' is cleared in the SOF ISR. Within the SLEEP Timer ISR, the same counter is incremented. If the SOF packets are not received for some time, the bCtr counter value will get incremented above definable threshold value at which the 'bDeviceEnumerated' flag is set to FALSE value.
Once the flag is set to FALSE, the firmware control reaches the enumeration API and enumerates the device on PC. With this firmware implementation, device works even after restarting the PC
This firmware is compliant with USB chapter 9 tests