high performance UART FIFO usage

Started by naderus2000 March 8, 2007
I want to uart0 for tx long string with FIFO mode enable.
what is the best performance wat to do that?I want the min time I
must wait in this function.
here is a simple function for that:

void UART0_String(char * str)
{
char i = 0;

while(!(U0LSR &0x20));// see in FIFO is full free from last
access

while(*str != '\0')
{
U0THR = *str++;
i++;
if(i == 16) // FIFO is full
{
while(!(U0LSR &0x20)); // wait until the FIFO free
i =0;
}
}
}

if my string is 18 char when 16 char is fill in the FIFO
I must wait the 16 char is sent (about 16*70us @ 115200)
but if i can detect when two char is send i only want
2*70us that's more effient.
Is there any way for better usage of FIFO with interrupt?

An Engineer's Guide to the LPC2100 Series

I don't think the UART can tell you if there is space in the FIFO
(except to say it is completely empty).
This is a limitation of the 16550 UART that the lpc family emulates.

I can think of two approaches:

1) Provide your own software FIFO - as big as you want
subject to available memory.

2) Use a spare hardware timer to predict how the UART FIFO will empty.

I strongly recommend approach 1.
If the software FIFO is big enough your call will not block.
And while you're at it, add a software FIFO for characters coming in.

Regards,
Danish

--- In l..., "naderus2000" wrote:
>
> I want to uart0 for tx long string with FIFO mode enable.
> what is the best performance wat to do that?I want the min time I
> must wait in this function.
> here is a simple function for that:
>
> void UART0_String(char * str)
> {
> char i = 0;
>
> while(!(U0LSR &0x20));// see in FIFO is full free from last
> access
>
> while(*str != '\0')
> {
> U0THR = *str++;
> i++;
> if(i == 16) // FIFO is full
> {
> while(!(U0LSR &0x20)); // wait until the FIFO free
> i =0;
> }
> }
> }
>
> if my string is 18 char when 16 char is fill in the FIFO
> I must wait the 16 char is sent (about 16*70us @ 115200)
> but if i can detect when two char is send i only want
> 2*70us that's more effient.
> Is there any way for better usage of FIFO with interrupt?
>