EmbeddedRelated.com
Forums

LPC2148: UART 1 data throughput problem

Started by Wool Gather January 2, 2011
Hi all,

Thank you so much in advance for any kind of help of suggetions.

Here is my problem,
Using LPC2148 i am trying to send more then 1MByte of file throught UART1 with
some data packet.
I got working UART INTRUPT based code from some site which is working fine.

Now the problem is that, when i am trying to send file data continuously using
UART 1, i am not able to read more than 15KByte bandwidth.
I configured UART to 115200/230400/460800 out of this three baud i am getting
15KByte @ 460800 with 4K of tramit buffer.

Do any one have any working code which can able to send data on uart intrupt
based and getting throughput more than 20KByte.

My LPC2148 board having 12MHz crystal, and it is possible for me to set baudrate
with 460800.

Please help me with this problem.

Thanks,
Wool

An Engineer's Guide to the LPC2100 Series

--- In l..., Wool Gather wrote:
>
> Hi all,
>
> Thank you so much in advance for any kind of help of suggetions.
>
> Here is my problem,
> Using LPC2148 i am trying to send more then 1MByte of file throught UART1 with
> some data packet.
> I got working UART INTRUPT based code from some site which is working fine.
>
> Now the problem is that, when i am trying to send file data continuously using
> UART 1, i am not able to read more than 15KByte bandwidth.
> I configured UART to 115200/230400/460800 out of this three baud i am getting
> 15KByte @ 460800 with 4K of tramit buffer.
>
> Do any one have any working code which can able to send data on uart intrupt
> based and getting throughput more than 20KByte.
>
> My LPC2148 board having 12MHz crystal, and it is possible for me to set baudrate
> with 460800.
>
> Please help me with this problem.
>
> Thanks,
> Wool
>
If the code you 'found' someplace is working fine, why is it so slow? Sometimes 'found' code isn't all that wonderful.

When the THRE interrupt occurs, it indicates that the FIFO is empty. Therefore, you should be dumping 16 chars into the FIFO on every interrupt. If your queue should run empty, it's ok to transfer less but be aware that there will be a one character wait if you transfer less than 2 bytes. In fact, transferring one byte at a time is guaranteed to cut your throughput in half. The chip is DESIGNED that way. See the next to the last paragraph of section 10.3.7.

For maximum throughput, you have one character transmission time to process the interrupt and get a couple of chars into the FIFO. You do not want the FIFO to run empty again before you have loaded 2 chars or that automatic delay will kick in.

In thinking about it, very high baud rates may be a mistake. Your code might not be capable of getting 2 chars in the FIFO during one character transmission time.

That interrupt and dequeue routine need to be FAST!

Richard

--- In l..., "rtstofer" wrote:

> For maximum throughput, you have one character transmission time to process the interrupt and get a couple of chars into the FIFO. You do not want the FIFO to run empty again before you have loaded 2 chars or that automatic delay will kick in.
>
> Richard
>

I wonder if it makes sense to create a circular buffer of 16 byte packets. That way there would be no need to check for an empty queue during each byte. At every interrupt, send the entire packet.

I guess it would also depend on the producer end of the queue and whether it can packetize the chars at a suitable rate.

Richard

My 2 cents ...

Without getting the whole picture it is hard to help you. Who is on the other side? What device are you sending these data to? If it is a Windows terminal program, it might be that it is the bottleneck.

I know from experience that sending a file from Hyperterminal is slow, because it does not send all data continously, like you want, but byte by byte with a pace that I can't relate to anything. In my case, I had to rely on the old reliable MS-DOS copy command like:

copy com5 /b

Beforehand, I would set the communication parameters with:

MODE COM5 BAUD#0400 PARITY=n DATA=8 STOP=1 to=off xon=on

These are self-explainable but you can type "help mode" to get the available options. Also, in your case, you might try:

copy com /b

BTW, all this worked flawlessly on a 2103 as well as on an 1114. No bytes lost running at 230K.

Hope that helps!

Julio de Melo

--- In l..., Wool Gather wrote:
>
> Hi all,
>
> Thank you so much in advance for any kind of help of suggetions.
>
> Here is my problem,
> Using LPC2148 i am trying to send more then 1MByte of file throught UART1 with
> some data packet.
> I got working UART INTRUPT based code from some site which is working fine.
>
> Now the problem is that, when i am trying to send file data continuously using
> UART 1, i am not able to read more than 15KByte bandwidth.
> I configured UART to 115200/230400/460800 out of this three baud i am getting
> 15KByte @ 460800 with 4K of tramit buffer.
>
> Do any one have any working code which can able to send data on uart intrupt
> based and getting throughput more than 20KByte.
>
> My LPC2148 board having 12MHz crystal, and it is possible for me to set baudrate
> with 460800.
>
> Please help me with this problem.
>
> Thanks,
> Wool
>

Hi Rechard,

I am complitly agree with your advice, i am not controlling FIFO size and
getting THRE intrupt on every one character.
I did search LPC2148 user manual, but i am not able to find how to set size of
TX FIFO.
I found that it is possible to set the size of RX FIFO, but how can i set the
size of TX FIFO ?

Your advice to use circular buffer, so THRE intrupt will not ganerate and
process will be more faster without intrupt, that is true.
But, how can i use this concept of circular buffer that is will bit difficlut
for me.
If you know any example which will help me to understand the way i can use
circular buffer then that will be great help.

Wool

________________________________
From: rtstofer
To: l...
Sent: Sun, January 2, 2011 9:26:55 PM
Subject: [lpc2000] Re: LPC2148: UART 1 data throughput problem

 
--- In l..., Wool Gather wrote:
>
> Hi all,
>
> Thank you so much in advance for any kind of help of suggetions.
>
> Here is my problem,
> Using LPC2148 i am trying to send more then 1MByte of file throught UART1 with

> some data packet.
> I got working UART INTRUPT based code from some site which is working fine.
>
> Now the problem is that, when i am trying to send file data continuously using

> UART 1, i am not able to read more than 15KByte bandwidth.
> I configured UART to 115200/230400/460800 out of this three baud i am getting
> 15KByte @ 460800 with 4K of tramit buffer.
>
> Do any one have any working code which can able to send data on uart intrupt
> based and getting throughput more than 20KByte.
>
> My LPC2148 board having 12MHz crystal, and it is possible for me to set
>baudrate
>
> with 460800.
>
> Please help me with this problem.
>
> Thanks,
> Wool
>

If the code you 'found' someplace is working fine, why is it so slow? Sometimes
'found' code isn't all that wonderful.

When the THRE interrupt occurs, it indicates that the FIFO is empty. Therefore,
you should be dumping 16 chars into the FIFO on every interrupt. If your queue
should run empty, it's ok to transfer less but be aware that there will be a one
character wait if you transfer less than 2 bytes. In fact, transferring one byte
at a time is guaranteed to cut your throughput in half. The chip is DESIGNED
that way. See the next to the last paragraph of section 10.3.7.

For maximum throughput, you have one character transmission time to process the
interrupt and get a couple of chars into the FIFO. You do not want the FIFO to
run empty again before you have loaded 2 chars or that automatic delay will kick
in.

In thinking about it, very high baud rates may be a mistake. Your code might not
be capable of getting 2 chars in the FIFO during one character transmission
time.

That interrupt and dequeue routine need to be FAST!

Richard
Hi Julio

I am not using any kind of windows application.
I am trying to send file to my other computer terminal using wireless module.
so i am using LPC2148 application to send data through UART1 which interface
with my wireless module.
my wireless module is capabale to send data with the rate of 3 Mbps.

So i have problem with UART driver and probley drier is not capable to send data
with required speed.

So, trying to find the solution which i can apply to UART driver.

Please do let me know if you have any confution or any more question for the
same.

Thanks,
Wool

________________________________
From: jcdmelo
To: l...
Sent: Mon, January 3, 2011 11:19:50 PM
Subject: [lpc2000] Re: LPC2148: UART 1 data throughput problem

 
My 2 cents ...

Without getting the whole picture it is hard to help you. Who is on the other
side? What device are you sending these data to? If it is a Windows terminal
program, it might be that it is the bottleneck.

I know from experience that sending a file from Hyperterminal is slow, because
it does not send all data continously, like you want, but byte by byte with a
pace that I can't relate to anything. In my case, I had to rely on the old
reliable MS-DOS copy command like:

copy com5 /b

Beforehand, I would set the communication parameters with:

MODE COM5 BAUD#0400 PARITY=n DATA=8 STOP=1 to=off xon=on

These are self-explainable but you can type "help mode" to get the available
options. Also, in your case, you might try:

copy com /b

BTW, all this worked flawlessly on a 2103 as well as on an 1114. No bytes lost
running at 230K.

Hope that helps!

Julio de Melo

--- In l..., Wool Gather wrote:
>
> Hi all,
>
> Thank you so much in advance for any kind of help of suggetions.
>
> Here is my problem,
> Using LPC2148 i am trying to send more then 1MByte of file throught UART1 with

> some data packet.
> I got working UART INTRUPT based code from some site which is working fine.
>
> Now the problem is that, when i am trying to send file data continuously using

> UART 1, i am not able to read more than 15KByte bandwidth.
> I configured UART to 115200/230400/460800 out of this three baud i am getting
> 15KByte @ 460800 with 4K of tramit buffer.
>
> Do any one have any working code which can able to send data on uart intrupt
> based and getting throughput more than 20KByte.
>
> My LPC2148 board having 12MHz crystal, and it is possible for me to set
>baudrate
>
> with 460800.
>
> Please help me with this problem.
>
> Thanks,
> Wool
>
--- In l..., Wool Gather wrote:
>
> Hi Rechard,
>
> I am complitly agree with your advice, i am not controlling FIFO size and
> getting THRE intrupt on every one character.
> I did search LPC2148 user manual, but i am not able to find how to set size of
> TX FIFO.
> I found that it is possible to set the size of RX FIFO, but how can i set the
> size of TX FIFO ?
>
> Your advice to use circular buffer, so THRE intrupt will not ganerate and
> process will be more faster without intrupt, that is true.
> But, how can i use this concept of circular buffer that is will bit difficlut
> for me.
> If you know any example which will help me to understand the way i can use
> circular buffer then that will be great help.
>
> Wool
I think BOTH FIFOs are 16 characters. For the RX interrupts, you can choose the FIFO level at which the interrupt occurs (1, 4, 8, 14 chars). For the TX interrupt, you get it when the last char is transferred out of the FIFO and into the transmit shift register. Whether you put one char or 16 on every interrupt is up to you. As soon as the FIFO empties out you will get another interrupt. The bad news: if you put less than 2 chars in the FIFO, the hardware will automatically stall for one char - cutting throughput in half. Actually, far less than half because you have to execute the interrupt routine for every THRE interrupt; one char or 16.

I was just thinking aloud about the best way to always send 16 bytes without having to check for an empty queue for every byte. I should probably keep it down.

Then I got to thinking about other ways to manipulate the queue pointers. Maybe it would work by not incrementing the insertion pointer until the producer has put 16 chars in the queue. But what if the producer just plain runs out of work and has only put 15 chars in the queue?

I think it is worth looking at different strategies for loading as many bytes as possible on every interrupt.

Richard

Hi,
I'm not familiar with the 2148 but on the 17xx parts, DMA is fairly easy to use and should go at the max rate of the UART. If the data is is large buffer DMA should work very well.
Nick
--- In l..., Wool Gather wrote:
>
> Hi all,
>
> Thank you so much in advance for any kind of help of suggetions.
>
> Here is my problem,
> Using LPC2148 i am trying to send more then 1MByte of file throught UART1 with
> some data packet.
> I got working UART INTRUPT based code from some site which is working fine.
>
> Now the problem is that, when i am trying to send file data continuously using
> UART 1, i am not able to read more than 15KByte bandwidth.
> I configured UART to 115200/230400/460800 out of this three baud i am getting
> 15KByte @ 460800 with 4K of tramit buffer.
>
> Do any one have any working code which can able to send data on uart intrupt
> based and getting throughput more than 20KByte.
>
> My LPC2148 board having 12MHz crystal, and it is possible for me to set baudrate
> with 460800.
>
> Please help me with this problem.
>
> Thanks,
> Wool
>