Help. USB issue

Discussion of the PSoC CY8C24x94 and other PSoC like USB parts from Cypress should be discussed here. This forum is limited to the discussion of USB portion of those parts. Other forums should still be used to discuss the non USB features of these parts.

Moderator: ericb

Help. USB issue

Postby chicagolar » Thu Feb 23, 2012 11:08 am

I am trying to get the bugs out of a previously designed system. The system uses a PSOC1 device for USB communication. (device is USB bus powered)
If the computer is already running and I plug in the USB it sees it and everything is fine. However, if the cable is already plugged in and I boot the computer it never sees the USB. Any ideas?
Here is the code.
Thanks everyone......
void main()
{
init_hardware();
M8C_EnableGInt;

USBFS_Start(0,USB_5V_OPERATION); // Connect to the host
while (!USBFS_bGetConfiguration()); // Wait to be enumerated
PGA_SetGain(PGA_G48_0);
PGA_Start(PGA_HIGHPOWER);
ADCINC_Start(ADCINC_HIGHPOWER);
MUX_CR3 = 0x04;
iCh = 1;
iFace = 0; //// 1.18
iTik = OFF;
SS1(OFF);
SS2(OFF);

ADCINC_GetSamples(0);
chicagolar
Newbie
Newbie
 
Posts: 4
Joined: Thu Feb 23, 2012 10:02 am

Re: Help. USB issue

Postby bobmarlowe » Fri Feb 24, 2012 1:59 am

That might have to do with your PC's operating system (presumably windows) which sometimes doesn't see a plugged USB-Device.
Can you setup a Timer and re-try the initialization if it doesn't enumerate in ,say 60 seconds?

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: Help. USB issue

Postby chicagolar » Sun Feb 26, 2012 12:39 pm

Thanks for the reply,
Yes I have set up a timer (30s) and this works but the delay is unacceptable because the delay is also there when you just plug in the cable.
The starange thing is I can see the USB device in device manager and it says it is working fine but the software does not see it. The software only sees it if I plug in the USB cable while the computer is already booted.
Perhaps the device is in suspend mode or something similar?
Or could this be a software issue?
I have never worked with PSOC before so any help would be greatly appreciated.
chicagolar
Newbie
Newbie
 
Posts: 4
Joined: Thu Feb 23, 2012 10:02 am

Re: Help. USB issue

Postby orob » Mon Feb 27, 2012 6:01 am

The problem you are having is one I have also encountered. You may find that if you reboot your system where the power never actually shuts off, the device with behave as you mention as well. In order to fix it, you must stop and restart the USB user module. The USB has its own section of ram and will not flush automatically when the computer reboots, so the usb device does not know to reenumerate when the pc reboots. Keep in mind that not every chipset does this though so it was difficult to repeat on every machine. To address this issue, I first put in a watch-dog timer. On certain devices, it would reset every few seconds until the driver completed loading... then I realized that it needed a simple check. If after a few seconds, the USB bus didn't send its timed signal, stop the user module and restart it and that fixed it for both the cold boot and warm boot/reset situations. try monitoring the :

Code: Select all
USBFS_bCheckActivity


If it times out based on your set interval timing, then stop and start the user module. Depending on how you set up your USB, the interval may or may not be visible to you. The exact code I wrote for this belongs to someone else, so I can't share it, but the concept is valid and will work for the problem you are seeing.
orob
The Big Cheese
The Big Cheese
 
Posts: 606
Joined: Wed Sep 26, 2007 9:06 am
Location: US

Re: Help. USB issue

Postby chicagolar » Wed Feb 29, 2012 7:57 am

Thanks for the help.
I tried to monitor USBFS_bCheckActivity and am able to detect when the communication stops. I then stop and restart the USBFS module with a short delay between each followed by the wait to be enumerated code. I then turn on an LED (no emulater available).
The LED turns on and everything seems correct but the application still cannot detect it. I have to remove and reinsert the USB connector for it to work again.
I know it's going thru the loop because the LED turns on after the wait to be enummerated code.
I am under the impression that USBFS_stop(), short delay, USBFS_start(0,USB_5V_OPERATION) , short delay, while (!USBFS_bGetConfiguration()); should act the same as removing and reinserting the USB plug correct? Or am I missing something?
Thanks again for your help....
chicagolar
Newbie
Newbie
 
Posts: 4
Joined: Thu Feb 23, 2012 10:02 am

Re: Help. USB issue

Postby orob » Wed Feb 29, 2012 8:31 am

That is correct, however if you only stop and start once, it may be trying to enumerate while the computer isn't ready and miss the opportunity. You might try something like this (using the code you provided):

Code: Select all
main (){
  while (1){
    if (!USBFS_bCheckActivity){  // is false for at least 5 seconds or whatever time interval you choose
      USBFS_stop();
      USBFS_start(0,USB_5V_OPERATION);
      while (!USBFS_bGetConfiguration()){
        //  put a timer in here so it does not hang indefinitely use one of the three following options:
        // M8C_Reset();  // option 1 manual reset of the entire controller
        // use the watch-dog timer and after 3 sleep timer events (3 seconds max) it will reset the entire controller.
        // option 2 put in a timer to break out of this loop and redo the stop start successively until it enumerates.
      }
    }
  }
}


The key is to make sure it does it over and over until the pc resets the usb bus and the device reenumerates. If you only do this once while the pc is booting, it may happen before the system has loaded the usb drivers and then it is in the same state it was before, so that stop, start while statement needs to be in your main while loop
orob
The Big Cheese
The Big Cheese
 
Posts: 606
Joined: Wed Sep 26, 2007 9:06 am
Location: US

Re: Help. USB issue

Postby chicagolar » Wed Feb 29, 2012 10:52 am

Thank you so much for the help.
Resetting the controller in the loop has so far worked perfectly in all instances.
I'm going to test it out now on other computers.
Thanks again, I greatly appreciate your assistance.

Lar
chicagolar
Newbie
Newbie
 
Posts: 4
Joined: Thu Feb 23, 2012 10:02 am

Re: Help. USB issue

Postby orob » Wed Feb 29, 2012 11:03 am

You are most welcome. I'm glad it worked. Do be sure to test a driver-loading scenario for the initial plug in to ensure that the pc will load the driver even if the chip resets while trying to enumerate.
orob
The Big Cheese
The Big Cheese
 
Posts: 606
Joined: Wed Sep 26, 2007 9:06 am
Location: US


Return to “%s” USB

Who is online

Users browsing this forum: No registered users and 1 guest

cron