Announcements
IMPORTANT: Cypress Developer Community currently doesn’t allow sign-in to prepare for the upcoming transition. To learn more, check out our announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1

Anonymous
Not applicable

hi,

   

I have a problem with uart_writetxdata().I have attached the code. The problem is UART is not able send all the digit as per the code.

   

the first line in for loop print four times on serial terminal. I have attached a pic of serial terminal.

   

Thanks in advanced

0 Likes
7 Replies
Bob_Marlowe
Expert II

WriteTxData() does not check for status (Tx Buffer free), so you constantly overwrite the transmitter. Better use PutChar(). See datasheet.

   

Your conversion algorithm is not correct, use Number + '0' to convert a digit between 0..9 to ASCII.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

oh thanks

   

The thing is PutChar takes longer time to transmit.. Can i reduce the loop time for transmitting data(say 4 to 8 bytes) through uart ?

   

Why does PutChar takes more time with increase in number of digits in number? The comparision of buffer should take equal time for any number of digit. am i right?

0 Likes
HeLi_263931
Honored Contributor II

PutChar takes longer since it actually waits for the character to be transmitted. Not doing so is naturally faster since just overwrites the output FIFO.

0 Likes
Bob_Marlowe
Expert II

Set the Tx buffer size to 100 and call CyGlobalIntEnable; This will help for the moment until the buffer gets filled. Transmitting is automatically done in background interrupt driven.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thank you..

   

Is there any way to check the current buffer size?

0 Likes
Bob_Marlowe
Expert II

The current buffer size is set in UART configuration dialog and cannot be changed by the program. You can check how many bytes already are in the buffer: Search in UART datasheet for TxBufferSize. This function returns number of bytes, not the size of the buffer as the name may suggest.

   

 

   

Bob

0 Likes
rola_264706
Honored Contributor II

How about using sprintf(buffer, "character: %c",c);
    UART_UartPutString(buffer);
    NewLine();

   

It would make the program simpler. or use this

   

 sprintf(buffer, "string: %s",s);
    UART_UartPutString(buffer);

   

Or this

   

sprintf(buffer, "unsigned decimal: %u",u);
    UART_UartPutString(buffer);

0 Likes