View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
USB cable disconnect detection |
Posted: Fri Oct 22, 2004 8:32 am |
|
|
Hi all,
I am having difficulty in detecting the disconnection of the USB connection between my PIC and PC. I am using a circuit identical to the USB development kit.
I would expect the disconnecting the cable would cause the usb_emumeration check on the PIC to become false ( call ) but this is not the case!
Usb_enumerated continues to be true even when you pull out the USB cable!
Is there anyway for the PIC to detect that the cable has been disconnected? I would have thought the device would no longer be enumerated when the cable is pulled but the ccs library is pretty complicated and I am having difficulty in following it!
Any advice much appreciated!
P.S. Interestingly when you re-plug the cable calls �usb_enumerated� do return false for a while until the device is re-enumerated! |
|
|
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Sat Oct 23, 2004 9:22 am |
|
|
I�ve dug a little deeper. The USBN9603 doesn�t appear to issue an interrupt on disconnection so the PIC stands no chance in knowing! I�ve searched the datasheet and can�t see a configuration which issues an interrupt on disconnect. In fact I can�t even find a register which contains a simple �bit� to signify if a connection is intact!
I thought of a work around in using, via a couple of resistors, the +5v line on the USB to indicate to the PIC when a PC was connected, bit of a bodge, but it would work OK.
Anyone used the USBN9603 and know how to configure it to interrupt on disconnect? Maybe it�s a USB �feature� because as far as I know the only way the USBN6093 will know it�s been disconnected is the fact the PC is no longer polling it as electrically (I believe) the bus is undetectable when idle? |
|
|
Ttelmah Guest
|
|
Posted: Sat Oct 23, 2004 10:45 am |
|
|
Will Reeve wrote: | I�ve dug a little deeper. The USBN9603 doesn�t appear to issue an interrupt on disconnection so the PIC stands no chance in knowing! I�ve searched the datasheet and can�t see a configuration which issues an interrupt on disconnect. In fact I can�t even find a register which contains a simple �bit� to signify if a connection is intact!
I thought of a work around in using, via a couple of resistors, the +5v line on the USB to indicate to the PIC when a PC was connected, bit of a bodge, but it would work OK.
Anyone used the USBN9603 and know how to configure it to interrupt on disconnect? Maybe it�s a USB �feature� because as far as I know the only way the USBN6093 will know it�s been disconnected is the fact the PC is no longer polling it as electrically (I believe) the bus is undetectable when idle? |
It's a common problem. USB, in places is c*^p....
Your device can use the 'poll' as you suggest, or check the power (beware, that sometimes the power line can get driven by the USB driver chip, and fail to drop as expected, unless this is diode isolated).
Best Wishes |
|
|
Guest
|
|
Posted: Sat Oct 23, 2004 10:53 am |
|
|
Do you mean Hardware disconnetion or software ?
The FTDI chip has the PWREN# which goes high during USB suspend and when the cable is removed.
Problem solved. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sat Oct 23, 2004 11:00 am |
|
|
From the datasheet
Quote: | This difference is particularly important for bus-powered operations. In such applications, the voltage provided by the bus
may fall below acceptable levels for the clock generation circuit. When this occurs, a reset must be applied to this circuit to
guarantee proper operation. After a delay of 214 XIN clock cycles, the CLKOUT signal is output. This low voltage detection
is typically accomplished in bus-powered applications using a voltage sensor, such as the LP3470, to appropriately reset
the CPU and other components, including the USBN9604. |
Reading this would lead me to believe that the chip will not detect it. |
|
|
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Tue Oct 26, 2004 3:14 am |
|
|
Thanks guys,
It does indeed appear that the �correct� (notice the � so as not to rattle the pro-FTDI camp (notice the smiley as well!)) way to monitor connect and disconnect is indeed with a sense on the 5v USB line. This goes for self powered and bus powered devices.
A good datasheet on techniques is here:
http://www.smsc.com/main/anpdf/an106.pdf
I�ve used a 3pin POR (power on reset) IC I had at hand for a few pence and a couple of resistors to do the job nicely. It has the added bonus of allowing me to only switch on the USBN9603 when I only need to (when the PIC detects a USB cable!). It works very well indeed.
A+ to the forum as usual!
Keep well all,
Will |
|
|
Guest
|
|
Posted: Tue Oct 26, 2004 11:58 am |
|
|
if that's all you wanted then FDTI has several examples showing how to do... |
|
|
Guest
|
|
Posted: Tue Oct 26, 2004 2:04 pm |
|
|
Will Reeve wrote: | Thanks guys,
It does indeed appear that the �correct� (notice the � so as not to rattle the pro-FTDI camp (notice the smiley as well!)) way to monitor connect and disconnect is indeed with a sense on the 5v USB line. This goes for self powered and bus powered devices.
A good datasheet on techniques is here:
http://www.smsc.com/main/anpdf/an106.pdf
I�ve used a 3pin POR (power on reset) IC I had at hand for a few pence and a couple of resistors to do the job nicely. It has the added bonus of allowing me to only switch on the USBN9603 when I only need to (when the PIC detects a USB cable!). It works very well indeed.
A+ to the forum as usual!
Keep well all,
Will |
That's correct and the FTDI chip has that integrated in it..
So it is also possible to monitor a USB suspend....
Hi Ho if you want to clutter your board with chips...
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Oct 26, 2004 2:38 pm |
|
|
Make me a mouse with a FTDI chip |
|
|
Guest
|
|
Posted: Tue Oct 26, 2004 9:25 pm |
|
|
Mark wrote: | Make me a mouse with a FTDI chip |
If all you need is a mouse buy one !
Reinventing the wheel is not fun... I can buy a USB mouse for pennies...
|
|
|
|