uart & waste time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

uart & waste time

1,318 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Sun May 19 07:15:31 MST 2013
Hi,

Actually trying new hardware with a LPC1374 and using USART, i've just seen something:

I'm sending many datas through an RS485 line, and use this code for USART sending (testing code):

LPC_USART->THR = Data;
while ( !(LPC_USART->LSR & LSR_THRE) );
LPC_USART->THR = Data;
while ( !(LPC_USART->LSR & LSR_THRE) );

On the scope, (when Data = 0xFF) the low level time on the Tx line, is something like 1us (@ 1Mbaud) that's ok, but time between two data is around 8us!!!!

Is it something i'm doing wrong, is it any way to reduce this time? Or is it normal?

Thx,

kabriolin.
0 Kudos
Reply
5 Replies

1,300 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Mon May 20 04:48:07 MST 2013
Sorry, forget everythings i said....

I'm totally wrong, I confused bit and byte....because I sent 0xFF, the Tx line get high after the start bit, and I took that for an idle time.

Everything is fine. Now I've to wait for the fifo empty flag :(.

Thx.
0 Kudos
Reply

1,300 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon May 20 02:25:52 MST 2013

Quote: kabriolin
If you have any idea.



I'm not sure what we are talking about  :confused:

Without seeing your code (especially UART setup) I can't follow you.

My good old 1343 is transmitting an 8N1 byte (a little bit faster than 1Mbit/s = 0.89us/bit) in about 9us.

So there are 90us needed for 10 bytes (if FIFO is empty).

That's what I'm seeing while scoping TxD :)

Which times are you expecting?
0 Kudos
Reply

1,300 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Mon May 20 00:48:08 MST 2013
New test,

GPIOSetBitValue(Debug_1_port, Debug_1_pin, 1);
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
GPIOSetBitValue(Debug_1_port, Debug_1_pin, 0);

The debug pin is high during 2.2uS, that's ok, but it takes 82us between the first byte and the end of the last one....
Instead of waiting between each byte, i have to wait for the last one.

I've also changed the baud rate (divided by 4), one byte transfert time 4us, and time between 2 bytes is 32us, but the fifo filling's time is always 2.2us.

So why is it waiting the equivalent time of 8 byte before sending the next one?
In the final apps, i'll have 5 or 6 uC echanging a lot of data, i can't wait a so long time. I will have a look on soft uart.

If you have any idea.
Thx.
0 Kudos
Reply

1,300 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kabriolin on Sun May 19 07:58:16 MST 2013
Sorry, it's LPC1347....:rolleyes: and it has a Tx FIFO.

I've tried this:
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;
LPC_USART->THR = 0xFF;

But always 8us between 2 bytes...
0 Kudos
Reply

1,300 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun May 19 07:40:30 MST 2013

Quote: kabriolin
Hi,

Actually trying new hardware with a LPC1374 and using USART, i've just seen something:

I'm sending many datas through an RS485 line, and use this code for USART sending (testing code):

LPC_USART->THR = Data;
while ( !(LPC_USART->LSR & LSR_THRE) );
LPC_USART->THR = Data;
while ( !(LPC_USART->LSR & LSR_THRE) );

On the scope, (when Data = 0xFF) the low level time on the Tx line, is something like 1us (@ 1Mbaud) that's ok, but time between two data is around 8us!!!!

Is it something i'm doing wrong, is it any way to reduce this time? Or is it normal?



I'm not sure what a LPC1374 is, but if it has a FIFO it's faster to use / fill it.

See #4 of http://knowledgebase.nxp.com/showthread.php?t=2231
0 Kudos
Reply