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
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.
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?
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.
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.
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.
How about using sprintf(buffer, "character: %c",c);
It would make the program simpler. or use this
sprintf(buffer, "string: %s",s);
sprintf(buffer, "unsigned decimal: %u",u);