- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello there,
I'm using the PSOC 5LP, which communicate with a PC using the USB port.
I'm using the USBFS block (and only 2 endpoints IN and OUT)
The communication fails if the PSOC is connected to the PC during the PC boot phase.
in this case, I need to disconnect the PSoC from the USB port and reconnect it back to have it working.
I'm using a PC with Linux, but my customer has the same experience on Windows as well.
Do you know what could be wrong?
I have tried code like this:
while(1) { // Start of main loop
/* check the USB still OK */
if(USBFS_IsConfigurationChanged()) {
if(!USBFS_GetConfiguration()) {
USBFS_Stop();
CyDelay(1000);
SerialResetBuffers(); // clear the serial buffers
USBFS_Start(0, USBFS_5V_OPERATION); // start up the USBUART
USBFS_SetPowerStatus(USBFS_DEVICE_STATUS_BUS_POWERED);
while(!USBFS_bGetConfiguration()); // Wait for Device to enumerate
while(USBFS_bGetEPState(IN)!= USBFS_IN_BUFFER_EMPTY) {}
USBFS_LoadInEP(IN, UsbTxBuff, 22);
USBFS_EnableOutEP(OUT);
} else {
USBFS_EnableOutEP(OUT);
}
}
// REST OF MAIN LOOP CODE
}
But it doesn't seem to make any difference.
Any idea?
Kind regards,
Francesco
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Tags:
- usb fail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Francesco,
You can also refer to the already existing USBUART code examples for PSoC5LP and follow the same structure in your code.
In PSoC Creator goto File > Code Example > In the device family select PSoC 5LP and Filter By select USBFS_UART.
Download the USBFS_UART project.
You can also follow the code structure:
in the main
/* Start USBFS operation with 5-V operation. */
USBUART_Start(USBFS_DEVICE, USBUART_5V_OPERATION);
for(;;)
{
/* Host can send double SET_INTERFACE request. */
if (0u != USBUART_IsConfigurationChanged())
{
/* Initialize IN endpoints when device is configured. */
if (0u != USBUART_GetConfiguration())
{
/* Enumeration is done, enable OUT endpoint to receive data from host. */
USBUART_CDC_Init();
}
}
/*Rest of the code */
}
Please let me know if this fixes the issue.
Regards
Ekta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Francesco,
I am using following structure for a CDC device.
USBUART_Start(0, USBUART_5V_OPERATION); // Initialize USBFS using 5V power supply
for(;;) {
// Wait for initialization completed
while (USBUART_GetConfiguration() == 0);
USBUART_IsConfigurationChanged(); // Ensure to clear the CHANGE flag
USBUART_CDC_Init(); // Initialize the CDC feature
for (;;) {
// Re-initialize if the configuration is changed
if (USBUART_IsConfigurationChanged()) {
break;
}
// CDC-OUT : Show the number of characters in a received line.
{
int16 ch = getch();
if (ch >= 0) {
nChars++;
if (ch == '\n') {
putdec32(nLine, 7);
putstr(" - ");
putdec32(nChars, 7);
putstr("\n");
nLine++;
nChars = 0;
}
}
}
// CDC-Control : Ignore all control commands
(void)USBUART_IsLineChanged();
}
The additional "USBUART_IsConfigurationChanged();" is required for Windows issuing 2nd SET_CONFIGURATION request to be ignored.
In the inner loop, SET_CONFIGURATION is checked to exit the loop to re-configuration, but the USB component is not stopped.
The EP buffer is handled with a periodic interrupts. If you are interested, please refer my repository GitHub - noritan/Design307: FIFO Implementation for USBUART for BLOG - "CY8C5888LTI-LP097" on "CY8CK...
Regards,
Noriaki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Francesco,
You can also refer to the already existing USBUART code examples for PSoC5LP and follow the same structure in your code.
In PSoC Creator goto File > Code Example > In the device family select PSoC 5LP and Filter By select USBFS_UART.
Download the USBFS_UART project.
You can also follow the code structure:
in the main
/* Start USBFS operation with 5-V operation. */
USBUART_Start(USBFS_DEVICE, USBUART_5V_OPERATION);
for(;;)
{
/* Host can send double SET_INTERFACE request. */
if (0u != USBUART_IsConfigurationChanged())
{
/* Initialize IN endpoints when device is configured. */
if (0u != USBUART_GetConfiguration())
{
/* Enumeration is done, enable OUT endpoint to receive data from host. */
USBUART_CDC_Init();
}
}
/*Rest of the code */
}
Please let me know if this fixes the issue.
Regards
Ekta