- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm sure I'm doing something stupid, but I need some guidance. I downloaded the attached Cypress code from Github to implement a UART through the USB on CY8C4246AZI-L433. At this point in time, I'm just trying to use the communication to provide me with feedback about my hardware. So I've added a small amount of additional code to send strings of data, converted to ASCII. Currently that string is just fixed at the number 65535. What comes out at my PC (I'm using Terraterm, but I tried Putty as well) is usually just the first two digits. Maybe every 20 or 30 times, a larger portion of the string will come across. Any help would be appreciated. (And apologies in advance for my less-than-superhuman software skills!).
Windows 10, Creator 4.4, my own hardware.
Dave
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Dave-san,
As I don't have a board with 4200L, I can not test the program on my side.
But seeing your program, I'm afraid that Number2String() may not be working OK.
Could you try the following?
Replace
======================
/* send a string */
loopcount=65535; // preset for predictable outcome
Number2String(loopcount,loopcountASCII);
loopcountASCII[5]=0; //just in case we need a null at the end of the string
USBUART_PutData(loopcountASCII,6);
USBUART_PutString("\n\r\0");
======================
With
======================
loopcount=65535 ;
snprintf(loopcountASCII, 6, "%d", loopcount) ;
USBUART_PutString(loopcountASCII) ;
USBUART_PutString("\n\r") ; // FYI, in C language "" has '\0' at the end.
======================
Best Regards,
22-Jan-2021
Motoo Tanaka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Motoo-san,
Thank you for that! It compiled fine. Interestingly Creator also, for some reason, decided to rebuild the hardware side as well. I'm glad to have learned about the snprintf() function! Unfortunately though, I'm still getting the same stuttered communication.
-Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Dave,
I tried to make the same changes as suggested by moto.
I also added
while (0u == USBUART_CDCIsReady())
{
}
statement between the two USBUART_Putstring() calls and I was able able to print properly.
=============================================================
loopcount= 65535;
snprintf(loopcountASCII, 6, "%d", loopcount) ;
USBUART_PutString(loopcountASCII) ;
while (0u == USBUART_CDCIsReady())
{
}
USBUART_PutString("\n\r") ; // FYI, in C language "" has '\0' at the end.
================================================================
This is because the USBUART_CDCIsReady function makes sure whether the device is ready to send more data to the PC. This function must be called before every USBUART_PutData(),USBUART_PutString(), USBUART_PutChar() or USBUART_PutCRLF() function.
I attaching the project. But I am not sure this is what you wanted.
Kindly let me know if my understanding of the issue is not clear.
Best Regards
Ekta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ekta, Thank you for that! I should have thought of it. It works!