Hi all,
First I would like to clarify the fact that I am using a PIC for my data transfer to and from a USB data storage device and I’m carefully counting my bytes. It is just that there is no need for the PIC to know what they are. In order to get the information of device disconnected you must monitor the data stream for the “No disk” message and I can’t afford to keep the PIC busy with that. So checking a pin status makes it really easy for me.
After reading the information (Yes, now I agree with the RTFM supporters 100%) on the LEDs behavior one solution to detect USB device disconnect “blinked” to me.
The LED2 output is supposed to be ON (Low) when the device is inserted and there is no data exchange on USART monitor port. If there is traffic the LED2 blinks. If the USB device is disconnected the LED2 is OFF (High).
I’m using a loop like:
Loop:
Read a string of 50 bytes from a open file on the USB device, via Debugin
Process and format the string
Send the string out via Serout2 to an other application (Hyper Terminal)
Check if USB device is present
Go to loop
As you can see it works for me due to the slight pause on activity on the monitor port.
I did not do a full test to see how fast you can expect the LED2 response but it is fast enough for me.
Hope this information will help people with similar applications.
Regards,
Nick




Bookmarks