12 Replies Latest reply on Dec 26, 2011 6:22 AM by gerhard.burger

    FX2 controller sometimes hangs on startup or on demand

    gerhard.burger

      Hello

         

      I have a custom design with CY7C68013a controller. Most of the time the device including software is working well but sometimes it seems that the there is a startup problem.

         

      The problem occurs at random. Sometimes, after power up (without connecting to a PC), it seems that the controller does not start
      Sometimes the controller starts and after I connect the USB cable the controller it hangs
      I am also able to set this hanging state if I put my finger to the D+ line of the USB.

         

      I already checked:
      Reset circuit
      Oscillator (24Mhz) and 22 pf capacitors
      power supply should be O.K.
      AVCC is separated from VCC by inductor MLB-160808-0300PN

         

      Does anybody have an idea what the problem could be please?

         

      Friendly regards and thak you for your hints in advance

         

      Geri
       

        • 1. Re: FX2 controller sometimes hangs on startup or on demand
          anand.srinivasan.asokan

           Geri,

             

          When you say hangs what is the behavior being seens?

             

          i.e. device not recognized pop-up, you've visual indication designed in which does not happen etc??

             

          Are you seeing this with only one board or all?

             

          Does your board follow the layout guidelines http://www.cypress.com/?rID=12982 ??

             

          Regards,

             

          Anand

          • 2. Re: FX2 controller sometimes hangs on startup or on demand
            gerhard.burger

            Hello Anand

               

            Thank you for your fast response. I currently only have one board available.

               

            The USB-Controller is combined with an FPGA. The FPGA gets the clock from the USB-Controller. If the USB chip runs, then I can measure the clock signal (CLKOUT, pin 1 of USB controller) and also the FPGA starts and a led blinks. If it hangs the clock signal  from the USB chip is low.

               

            So also without connecting the USB controller to a PC it sometimes hangs.

               

            I also detected a further point. My power supply is on the same socket as my oscilloscope. If the USB device is connected to the PC and runs and I switch on the oscilloscope, the device will be disconnected for around two seconds an then resatarts working.

               

            The power comes from a laboratory power supply to a DCDC (5V) and then 3.3 V linear regulator. The DCDC is not on board.

               

            I used the layout guidelins for my hardware design. I have a double layer design:) but I studied some working of them. D+ and D- are very short (around 15 mm) without vias, Crystal very short lines (around 10 mm), power supply of the chip should also be OK, reset is done by a ST811TW16F IC.

               

            Thank you for any hints and best regards

               

            Geri

             

            • 3. Re: FX2 controller sometimes hangs on startup or on demand
              anand.srinivasan.asokan

              Going by your description these are 2 things I would check

                 

              1. Is the power supply stable enough? When the oscilloscope is turned on/off is there a glitch seen on FX2LP supply lines?

                 

              2. When CLKOUT goes off (hang condition) what is the state of crystal input i.e. is FX2LP core running but CLKOUT or FX2LP itself is not running

                 

              Regards,

                 

              Anand

              • 4. Re: FX2 controller sometimes hangs on startup or on demand
                gerhard.burger

                Hello Anand

                   

                @1: I will think about how to measure this event

                   

                @2: The crystal stops to oscillate:

                   

                If the crystal oscillates (controller is working) then I can measure 24 Mhz clock with Minimum Peak 1V and maximum peak 1.6 V. I see a sin wave with my 100 MHz-oscilloscope.

                   

                If the USB-controller hangs, the crystal stops to oscillate.

                   

                Friendly regards and thank you for your help

                   

                Gerhard

                • 5. Re: FX2 controller sometimes hangs on startup or on demand
                  anand.srinivasan.asokan

                  Following are few of things that can cause the oscillation to stop

                     

                  1. The crystal is being overdriven. (Does the crystal used meet all the requirement specified in FX2LP datasheet?)

                     

                  2. FX2LP is detecting a suspend (is your code written to stay ON when no USB connection is there?)

                     

                  Regards,

                     

                  Anand

                  • 6. Re: FX2 controller sometimes hangs on startup or on demand
                    gerhard.burger

                    Hello Anand

                       

                    Thank you very much for your hints!

                       

                    @1: I know the specification of the crystal but I will replace it on my board.

                       

                    @2: If the USB cable is not connected to my board then the oscillator is still oscillating.  PA3 is used for USB wakeup.

                       

                    Then if I put my finger to the D+ line the crystal stops to oscillate. Moste of the time a reset is enough to restart the USB-controller, sometimes not. For my understanding, if the crystal normally do not stop, the USB-controller do not switch to suspend mode.

                       

                    Attached the code of the main code:

                       

                    void main(void)
                    {

                       

                    ...  

                       

                    EZUSB_IRQ_ENABLE();            // Enable USB interrupt (INT2)
                       EZUSB_ENABLE_RSMIRQ();            // Wake-up interrupt

                       

                       INTSETUP |= (bmAV2EN | bmAV4EN);     // Enable INT 2 & 4 autovectoring

                       

                       USBIE |= bmSUDAV | bmSUTOK | bmSUSP | bmURES | bmHSGRANT;   // Enable selected interrupts
                       EA = 1;                  // Enable 8051 interrupts
                     

                       

                    ..... 

                       

                    // Task Dispatcher
                       while(TRUE)               // Main Loop
                       {
                          // Poll User Device
                          TD_Poll();

                       

                          // Check for pending SETUP
                          if(GotSUD)
                          {
                             SetupCommand();          // Implement setup command
                             GotSUD = FALSE;          // Clear SETUP flag
                          }

                       

                          // check for and handle suspend.
                          // NOTE: Idle mode stops the processor clock.  There are only two
                          // ways out of idle mode, the WAKEUP pin, and detection of the USB
                          // resume state on the USB bus.  The timers will stop and the
                          // processor will not wake up on any other interrupts.
                          if (Sleep)
                          {
                             if(TD_Suspend())
                             {
                                Sleep = FALSE;     // Clear the "go to sleep" flag.  Do it here to prevent any race condition between wakeup and the next sleep.
                                do
                                {
                                   EZUSB_Susp();         // Place processor in idle mode.
                                }
                                while (!Rwuen && EZUSB_EXTWAKEUP());
                                // above.  Must continue to go back into suspend if the host has disabled remote wakeup
                                // *and* the wakeup was caused by the external wakeup pin.

                       

                                // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
                                EZUSB_Resume();   // If source is the Wakeup# pin, signal the host to Resume.     
                                TD_Resume();
                             }  
                          }

                       

                       }
                    }
                     

                       

                    Friendly regards

                       

                    Geri

                    • 7. Re: FX2 controller sometimes hangs on startup or on demand
                      anand.srinivasan.asokan

                      A self-power design cannot differentiate between disconnect and suspend condition using USB lines. So a GPIO is needed to do this.     Details on VBUS monitoring.

                         

                      When you plug out the cable the USB lines are floating so they MAY NOT go to idle state as expected. So the USB device (any device for that matter) MAY detect a suspend condition or it MAYNOT. In your case it is not detecting and when you place a finger it is most probably getting grounded and FX2LP is detecting suspend state.

                         

                      Your code is working with the normal suspend execution (if suspend detected put FX2LP in suspend to meet the current requirement), if you want your design to work under "no USB connection" condition as well then you've modify that routine accordingly. 

                         

                      Cheers,

                         

                      Anand

                      • 8. Re: FX2 controller sometimes hangs on startup or on demand
                        gerhard.burger

                        Hello Anand

                           

                        Thank you for the important hint! I changed the firmware according to the datasheet with IO polling method and the USB-Controller works very fine. The problem with the finger also no more exists as the D+ line is switchd off if the USB-cable is not plugged in.

                           

                        The only problem I still have is the sensitivity against other devices if they are switched on or off. In my case e.g. if I shut off my soldering iron, the USB connection is lost for a short time.
                        I assume it is someting with the power supply. If you have an idea what I could do to improve the situation, it would be very fine.

                           

                        Merry Christmas

                           

                        Geri

                        • 9. Re: FX2 controller sometimes hangs on startup or on demand
                          anand.srinivasan.asokan

                           Observe the supply line of FX2LP to see if the glitch on the line is the reason behind your issue. If so add enough capacitance on the supply to withstand the glitch.

                             

                          Regards,

                             

                          Anand

                          • 10. Re: FX2 controller sometimes hangs on startup or on demand
                            gerhard.burger

                            Hello Anand

                               


                            Thank you for your hints. I will try to improve the power supply and let you know about the results. Before I try to do some measurement to get an estimation about its quality.

                               

                            Friendly regards and thank you very much again!

                               

                            Gerhard

                            • 11. Re: FX2 controller sometimes hangs on startup or on demand
                              victor.selvaraj

                              How to write code to keep the firmware to stay ON when there is no USB connection? What should I do? I also have a self powered system that goes into SUSPEND and never comes out of it. I had to disable the whole if(Sleep) block in the main method. 

                              • 12. Re: FX2 controller sometimes hangs on startup or on demand
                                victor.selvaraj

                                In my board, the VBUS is left un connected. I cannot use VBUS monitoring. Is there any other way to handle suspend and resume correctly? Is there an APP note I can follow. I used AN61345 for my initial design.