5 Replies Latest reply on Aug 27, 2016 1:46 AM by JoMe_264151

    USBUART Question

      The sample code suggests code like this...


      /* Wait until component is ready to send data to host. */
      while (0u == USBUART_CDCIsReady())


      Is it possible to get stuck in this loop if there is a problem with the USB connection?

        • 1. Re: USBUART Question

          Welcome in the forum!


          You can get stuck depending on the state of the USBUART.


          I would suggest you to modify one of the example projects for your need. Right click on the USBUART component (on your topdesign or in component catalog) and select "Find Code Example".




          Happy coding



          • 2. Re: USBUART Question

            That is the example code for USBFS_UART.  Is there another example project?


            Can a timer be used as a way to get unstuck?  What is a reasonable duration?

            • 3. Re: USBUART Question

              Does the unmodified example project get stuck in USBFS-UART?


              What changes did you exactly make?


              Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
              Creator->File->Create Workspace Bundle (minimal)
              and attach the resulting file.





              • 4. Re: USBUART Question
                        I did not modify the code and it has not gotten stuck, but that while statement looks vulnerable. Your initial response makes me more worried.   
                • 5. Re: USBUART Question

                  Sorry, this is a misunderstanding.


                  The while-loop you questioned in your first post will indeed wait until the connection is OK. In a real project you may of course try it only once and ask to connect when failed. But how to "ask" when using a prototyping kit? (Light an LED, try in a while until OK, then switch off the LED.) You cannot proceed with the project when the USB connection is not established.