cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kres
Newbie
Newbie
563 Views
Registered: ‎10-28-2019

Sending long character string with UARTLite

Jump to solution

Hello,

I have the following code:

char test_text[32];

memset(&test_text[0], 0, sizeof(test_text));

sprintf(test_text, "abcdefgh12345678ijklmno12345$$$");  // 31 characters to allow for termination nul

for (unsigned int i = 0; i < sizeof(test_text); i++)
{
u8 current = test_text[i];
XUartLite_Send(&UART_USB, (u8*)&current, 1);
}

 The idea is that I need to send large character arrays via uart, but knowing that UartLite has a 16-byte FIFO buffer, I send one character out at a time.

I have an external program that reads continously until "$$$". As long as test_text is 16 bytes or smaller and ends with $$$, the communication is succesful and the external program receives all the bytes. But communication fails when test_text is bigger than 16 bytes.

I must be missing something here, does anyone know why the above idea does not work?

Thank you very much,

Kris

0 Kudos
1 Solution

Accepted Solutions
drjohnsmith
Teacher
Teacher
554 Views
Registered: ‎07-09-2009

on assumption processor is running at many MHz, and UART is sending characters at few thousand per second, 

    how are you stopping sending data to the fifo when its full ?

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

View solution in original post

4 Replies
drjohnsmith
Teacher
Teacher
555 Views
Registered: ‎07-09-2009

on assumption processor is running at many MHz, and UART is sending characters at few thousand per second, 

    how are you stopping sending data to the fifo when its full ?

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

View solution in original post

kres
Newbie
Newbie
534 Views
Registered: ‎10-28-2019

That is indeed the case.. I have since implemented a while loop: 'while(XUartLite_IsSending(&UART_USB) == 1);' before the Uartlite send function, and it works fine. Thank you very much!

Rmccarty
Adventurer
Adventurer
525 Views
Registered: ‎09-05-2020

Now you are blocking the processor to basically run at the same speed as the uart. Use an interrupt to load new bytes when the the uart is ready.

kres
Newbie
Newbie
517 Views
Registered: ‎10-28-2019

Yup, I plan to do that. I should have specified that my reply to drjohnsmith was a test. But this is the practice anyone else looking at this thread for a solution should go with.