PSoC4200L USBFS UART Stutter

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
DaBa_1448511
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

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

0 Likes
1 Solution
DaBa_1448511
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

Ekta, Thank you for that! I should have thought of it. It works!

View solution in original post

0 Likes
4 Replies
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

 

0 Likes
DaBa_1448511
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

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

0 Likes
lock attach
Attachments are accessible only for community members.
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

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

DaBa_1448511
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

Ekta, Thank you for that! I should have thought of it. It works!

0 Likes