You are here

USBUART Question | Cypress Semiconductor

USBUART Question

Summary: 5 Replies, Latest post by Bob Marlowe on 27 Aug 2016 01:46 AM PDT
Verified Answers: 2
Last post
Log in to post new comments.
bdring's picture
User
2 posts

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?

 

 

user_1377889's picture
User
10403 posts

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

Bob

bdring's picture
User
2 posts

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?

user_1377889's picture
User
10403 posts

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.

 

Bob

 

BartDring's picture
User
2 posts

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.

user_1377889's picture
User
10403 posts

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.

 

Bob

Log in to post new comments.