- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I need to know if there is a USB cable connected or not. How can i do that. I need this for reading by an FPGA
Thanks for your help
Regards
Franck RAUX
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Franck,
- Can you please share the USB traces captured using a logic analyzer before and after removing the cable? When the USB cable is removed, there should be no data transfers to the device and the D+/D- lines will be inactive.
- As an alternate approach, you can use any of the GPIO pins of FX2LP to monitor the VBUS pins of the USB connector. This pin can be monitored in the firmware for the presence of USB connection. Please check if this method is feasible with your design.
if ( !(IOA & 0x80) ) // if VBUS not present (using a PORTA.7 pin for example)
{
// take action and set the DISCON bit to disconnect FX2LP from USB
USBCS |= bmDISCON; // Setting DISCON bit disables the pull up on D+
}
else
{
USBCS &= ~bmDISCON; // Clear DISCON
// Proceed to do other tasks
}
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Franck,
The USB interrupts can be used to identify the connection. Among the different interrupts available, the USB Bus reset interrupt or the SOF Token interrupt can be used to identify the communications happening on the bus which indicates the establishment of USB connection.
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Srinath,
Thanks for your helping. I follow your advice but it doesn't work properly. I use the interrupt SUSP. In TD init i enable the interrupt
USBIE = bmSUSP and two outputs PA0 and PA1 OEA = 0x03 I used PA1 at the end of TD init to inform FPGA. and i use PA0 in a function interruupt like this :
void ISR_Susp(void) interrupt 0
{
PA0 = 1;
EZUSB_IRQ_CLEAR();
USBIRQ = bmSUSP;
}
I wait when i disconnect the USB connector PA0 go high. Sometime the PA0 go high and sometime it doesn't change. When it doesn't change when i disconnect, after i connect again the connectot and the PA0 go high. I don't understand what i forget. Thanks for your help.
regards
Franck RAUX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Franck,
USB Suspend is a low power state. The device may not enter this state when it is being disconnected from the host. Kindly, use the SOF interrupt which can indicate an active USB connection.
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Srinath,
I used the SOF interrrupt. I write the code bellow just to see the behavior od this interrupt :
void ISR_Sof(void) interrupt 0
{
PA0 = ~PA0;
EZUSB_IRQ_CLEAR();
USBIRQ = bmSOF; // Clear SOF IRQ
}
PA0 is an output. The USB cable is plug in. When i load the program in RAM, the PA0 change ist state at 125µs so it is what i wait but when i pluq out the USB cable, why the PA0 continue to change its state? Normally there is no connection between the host and the EZ-USB
regards
Franck R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Franck,
- Can you please share the USB traces captured using a logic analyzer before and after removing the cable? When the USB cable is removed, there should be no data transfers to the device and the D+/D- lines will be inactive.
- As an alternate approach, you can use any of the GPIO pins of FX2LP to monitor the VBUS pins of the USB connector. This pin can be monitored in the firmware for the presence of USB connection. Please check if this method is feasible with your design.
if ( !(IOA & 0x80) ) // if VBUS not present (using a PORTA.7 pin for example)
{
// take action and set the DISCON bit to disconnect FX2LP from USB
USBCS |= bmDISCON; // Setting DISCON bit disables the pull up on D+
}
else
{
USBCS &= ~bmDISCON; // Clear DISCON
// Proceed to do other tasks
}
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Srinath,
I have an other question. We use this component since many year. Sometimes we lost the communication for unknown reason and it is necessary to shutdown the power supply. It si too long for our customer. We would like to monitor the communication. How can we do this? You have to know that we are in FIFO SLAVE. We use the FIFO6 for transfer the data from the FPGA to the PC. The Power supply of the cypress is done not by the cable but from our card.
Regards
Franck RAUX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sorry i complete my question. After a detection of a commincation lost, how i can restart this communication the easiest and fastest way.
Regards
Franck RAUX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Franck RAUX,
Please let me know what you mean by "communication lost". Is the device getting suspended or is the device missing from the device manager?
If the device is disappearing from the device manager, it indicates that the FX2LP has lost its supply which in your case is obtained from the external power supply. So, please ensure that the power supply is stable.
If the device is getting suspended, the communication can be resumed by any USB transfer. In case you want to prevent the device from getting suspended, modify the configuration descriptor to disable "Remote Wakeup Suspend" feature.
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Srinath,
What i mean by "communication lost" is : in the plant, there is a lot of electromagnetic perturbation come from motors, inverter, etc... The USB communication can stop for unknown reason. Probably electromagnetic perturbation. With the FPGA we can know there is a problem because the internal FIFO stay full and this FPGA can activate an output to the CY7C68013 to restart the USB but we can restart by the firmware the communication.
There is no problem with the supply.
Regards
Franck RAUX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Franck RAUX,
- Please check if the device is disconnected from the device manager of the host when there is a loss of communication.
- To virtually connect the device back to the host, use the below statement. This may be called from an interrupt generated by the FPGA.
USBCS &=~bmDISCON; // Re-connect FX2LP back to the host.
Best regards,
Srinath S