Author Topic: USB 2.0 device takes 20 seconds for W7 to indicate removal after power down.  (Read 11600 times)

mihooper

  • Member
  • ***
  • Posts: 24
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.
« Last Edit: August 04, 2014, 04:59:46 pm by mihooper »
Thx,
MikeH

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
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.

mihooper

  • Member
  • ***
  • Posts: 24
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.
« Last Edit: August 04, 2014, 05:39:48 pm by mihooper »
Thx,
MikeH

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
I don't know of any way to speed it up.

Barry Twycross

  • Frequent Contributor
  • ****
  • Posts: 263
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.

mihooper

  • Member
  • ***
  • Posts: 24
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).
Thx,
MikeH