Author Topic: hong long does a device need to detach before reattaching  (Read 7409 times)

mdlayt

  • Member
  • ***
  • Posts: 40
hong long does a device need to detach before reattaching
« on: December 10, 2010, 06:14:09 pm »
I had my device programmed to detach for two or three seconds, then reattach, and all was well.  I tried halving the delay and, boom goes the dynamite, either Windows crashes or it puts me (and the hub above) on the bad list (of ports that it doesn't pay attention to ever again).  It looks like uninstalling the hub device gets me back to a working port--faster than a reboot.....but....

Hasn't someone put a number on how long a device must be detached?

So far I've searched the USB 2.0 spec, Microsoft, Microchip, and Cypress and the first page of Google.  Below is about the best I've found so far.  I especially enjoy the comment about "last ditch effort"--in the context of a reference design that relies on it.

(Note that in the LVR reference fwhid.zip it is buried in EZUSB_Discon--I think.)

Mike


; *********************************************************************
; USB Soft Detach
; Clears the DEV_ATT bit, electrically disconnecting the device to the bus.
; This removes the device from the bus, then reconnects so it can be
; re-enumerated by the host.  This is envisioned as a last ditch effort
; by the software.
; *********************************************************************
SoftDetachUSB
    global  SoftDetachUSB

    banksel UCTRL
    bcf     UCTRL,DEV_ATT   ; clear attach bit

    bcf     STATUS, RP0     ; bank 2

    clrf    outer
    clrf    inner

    incfsz  inner,f
    goto    $-1
    incfsz  outer,f
    goto    $-3

    pagesel InitUSB
    call    InitUSB         ; reinitialize the USB peripheral
    return

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: hong long does a device need to detach before reattaching
« Reply #1 on: December 10, 2010, 09:59:36 pm »
It's not in the specs or compliance testing anywhere that I've seen. If you want to program your device to detach and reattach in firmware, I would say give it a delay that causes no problems in your tests, then double it if you want to be safe.

Jan