PORTS Forum

Ports and Interfaces => USB => Topic started by: mihooper on August 04, 2014, 04:56:31 pm

Title: USB 2.0 device takes 20 seconds for W7 to indicate removal after power down.
Post by: mihooper on August 04, 2014, 04:56:31 pm
Is it normal for Windows 7 to take ~20-25 seconds before it sends a Device Removal Complete (DBT_DEVICEREMOVECOMPLETE = 0X8004) message after power is removed from the USB device? I am consistently seeing 20 - 25 second delay before this notification arrives at my application (using Generic HID ~5...I think). This delay is causing lots of problems for my firmware upgrade application which relies on the device being accurately detected (arrival and removal).

Also, if I put a break point at the OnDeviceChange message parser, there are ~20-25 identical messages queued up that continue to be serviced by the function.

protected override void WndProc(ref Message m)
        {
            try
            {
                //  The OnDeviceChange routine processes WM_DEVICECHANGE messages.

                if (m.Msg == DeviceManagement.WM_DEVICECHANGE)
                {
                    OnDeviceChange(m);
                }

Any thoughts would be greatly appreciated.
Title: Re: USB 2.0 device takes 20 seconds for W7 to indicate removal after power down.
Post by: Jan Axelson on August 04, 2014, 05:15:09 pm
Does the device emulate detach (for example, remove the pull-up for low or full speed)?

The newest version of my HID application uses System.Management class (WMI) to detect device arrival and removal rather than WM_DEVICECHANGE.
Title: Re: USB 2.0 device takes 20 seconds for W7 to indicate removal after power down.
Post by: mihooper on August 04, 2014, 05:37:03 pm
Jan,

Yes. The device is actually my own hardware design (using TI MSP430). I have designed it so that D+ goes to zero volts when the device powers down. I can see the voltage on the D+ pin go to zero, but the message takes ~20 seconds to arrive at my application. Weird.
Title: Re: USB 2.0 device takes 20 seconds for W7 to indicate removal after power down.
Post by: Jan Axelson on August 05, 2014, 11:31:27 am
I don't know of any way to speed it up.
Title: Re: USB 2.0 device takes 20 seconds for W7 to indicate removal after power down.
Post by: Barry Twycross on August 06, 2014, 01:19:26 am
Does it take that long if actually unplug the device?

If it does there may not be anything you can do about it. If it doesn't, then I'd suspect that you're not dropping D+ fast enough. If you've measured it dropping fast, you measurement may speed up the discharge.
Title: Re: USB 2.0 device takes 20 seconds for W7 to indicate removal after power down.
Post by: mihooper on August 06, 2014, 11:55:20 am
Quote
Does it take that long if actually unplug the device?
Yes. This is what confuses me. It's like the USB driver is not seeing the disconnect. Weird.
Quote
If it does there may not be anything you can do about it. If it doesn't, then I'd suspect that you're not dropping D+ fast enough. If you've measured it dropping fast, you measurement may speed up the discharge.
D+ drops to zero volts in a few microseconds. I'm measuring with a x10 scope probe (Mohms).