- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you..
Is there any way to check the current buffer size?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);