EmbeddedRelated.com
Forums

UART communication @ 1 Mbps or more

Started by Richard Duits March 3, 2008
Hallo All,

I am trying to let two boards communicate over a RS485 link at 3
megabits per second. One board has a LPC2368 and the other has a
LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
and are using the PLL to run at 48 MHz. The RS485 tranceivers are
capable of 12 Mbps.

Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
transmission has a unacceptable number of errors (more than 1 per
second). When I let the LPC2368 communicate between UART1 and UART2 via
the RS485 tranceivers there are no errors up to 3 Mbps.

Has anyone tried anything similar to this or do you have a suggestion
how to get the serial link (nearly) error free?

Regards,
Richard Duits

An Engineer's Guide to the LPC2100 Series

Does your hardware suport this baud rate?

Spin

2008/3/3, Richard Duits :
>
> Hallo All,
>
> I am trying to let two boards communicate over a RS485 link at 3
> megabits per second. One board has a LPC2368 and the other has a
> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
> capable of 12 Mbps.
>
> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
> transmission has a unacceptable number of errors (more than 1 per
> second). When I let the LPC2368 communicate between UART1 and UART2 via
> the RS485 tranceivers there are no errors up to 3 Mbps.
>
> Has anyone tried anything similar to this or do you have a suggestion
> how to get the serial link (nearly) error free?
>
> Regards,
> Richard Duits
>
>
Hello Alexandre,

I cannot find any limits in the datasheet/user manual of the LPC chips
and the RS485 tranceiver will go up to 12 Mbps. Those are the only
relevant components for this problem, so in theory the hardware should
support it. For 3 Mbps the UART will need a clock of 3 * 16 = 48 MHz,
which is the same as my PCLK.

Regards,
Richard.
Alexandre Umino (Spin) wrote:
> Does your hardware suport this baud rate?
>
> Spin
>
> 2008/3/3, Richard Duits :
>
>> Hallo All,
>>
>> I am trying to let two boards communicate over a RS485 link at 3
>> megabits per second. One board has a LPC2368 and the other has a
>> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
>> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
>> capable of 12 Mbps.
>>
>> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
>> transmission has a unacceptable number of errors (more than 1 per
>> second). When I let the LPC2368 communicate between UART1 and UART2 via
>> the RS485 tranceivers there are no errors up to 3 Mbps.
>>
>> Has anyone tried anything similar to this or do you have a suggestion
>> how to get the serial link (nearly) error free?
>>
>> Regards,
>> Richard Duits
>>
>>
>>
Richard Duits ha scritto:
>
> Hallo All,
>
> I am trying to let two boards communicate over a RS485 link at 3
> megabits per second. One board has a LPC2368 and the other has a
> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
> capable of 12 Mbps.
>
> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
> transmission has a unacceptable number of errors (more than 1 per
> second).
What error type? Missing data or corrupted data?
When I let the LPC2368 communicate between UART1 and UART2
> via the RS485 tranceivers there are no errors up to 3 Mbps.
>
> Has anyone tried anything similar to this or do you have a suggestion
> how to get the serial link (nearly) error free?
>
> Regards, Richard Duits
>
> -------------------------
>
> No virus found in this incoming message. Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.21.3/1307 - Release Date:
> 02/03/2008 15.59
On Mon, 03 Mar 2008 16:59:06 +0100, you wrote:

>Richard Duits ha scritto:
>>
>> Hallo All,
>>
>> I am trying to let two boards communicate over a RS485 link at 3
>> megabits per second. One board has a LPC2368 and the other has a
>> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
>> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
>> capable of 12 Mbps.
>>
>> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
>> transmission has a unacceptable number of errors (more than 1 per
>> second).
>What error type? Missing data or corrupted data?
>When I let the LPC2368 communicate between UART1 and UART2
>> via the RS485 tranceivers there are no errors up to 3 Mbps.
There is an issue on parts with fractional barudrate dividers, where you can set up a baudrate that
works OK for transmit but receive is unreliable - you need to ensure that the PCLK divides to
baud/16 exactly - you can get FDR combinations that appear to work out, and do function for
transmission, but not for receive.

e.g. at 60MHz PCLK, you can't get exactly 1mbit (1m x16 does not go into 60 exactly) , but you can
do 1.25M (1.25x16 , x3`) and 1.875. In principle you should be able to do 3.75 but not sure if
this actually works.
I've had 1.25M receive working reliably on a 2136/01 at 60MHz.

With the clock rates you give above ( assuming PCLK is not being divided), 1,2 and 3mbits should be
possible.
At very high rates there may also be issues with things like input pin synchronisation delays,
asymmetrical delay in teh driver and noise/jitter.

Also at high rates, the VIC unexpected interrupt issue starts to become more likely to occur - not a
problem as long as you set the VIC unexpected int vector to return instead of reset ( some compiler
examples default to the latter), and empty the rx fifo completely when you get an rx int.

The issue is that you can get a rx timeout int, but more data then comes along so when it get
serviced there is no apparent interrupt cause - this has been discussed here a few months ago.
>> Has anyone tried anything similar to this or do you have a suggestion
>> how to get the serial link (nearly) error free?
>>
>> Regards, Richard Duits
>>
>>
>>
>> -------------------------
>>
>> No virus found in this incoming message. Checked by AVG Free Edition.
>> Version: 7.5.516 / Virus Database: 269.21.3/1307 - Release Date:
>> 02/03/2008 15.59
>
>
Hi,
How much is RS-485 cable length between two boards.?


Ravi

On Mon, 03 Mar 2008 Richard Duits wrote :
>Hello Alexandre,
>
>I cannot find any limits in the datasheet/user manual of the LPC chips
>and the RS485 tranceiver will go up to 12 Mbps. Those are the only
>relevant components for this problem, so in theory the hardware should
>support it. For 3 Mbps the UART will need a clock of 3 * 16 = 48 MHz,
>which is the same as my PCLK.
>
>Regards,
>Richard.
>Alexandre Umino (Spin) wrote:
> > Does your hardware suport this baud rate?
> >
> > Spin
> >
> > 2008/3/3, Richard Duits :
> >
> >> Hallo All,
> >>
> >> I am trying to let two boards communicate over a RS485 link at 3
> >> megabits per second. One board has a LPC2368 and the other has a
> >> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
> >> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
> >> capable of 12 Mbps.
> >>
> >> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
> >> transmission has a unacceptable number of errors (more than 1 per
> >> second). When I let the LPC2368 communicate between UART1 and UART2 via
> >> the RS485 tranceivers there are no errors up to 3 Mbps.
> >>
> >> Has anyone tried anything similar to this or do you have a suggestion
> >> how to get the serial link (nearly) error free?
> >>
> >> Regards,
> >> Richard Duits
> >>
> >>
> >





Hello Ravi,

The cable is just a few centimeters. Also I cannot find any diffirence
between the short cable and a long cable (ca. 50 meters).

Regards,
Richard.
Ravi wrote:
> Hi,
> How much is RS-485 cable length between two boards.?
>
>
> Ravi
>
> On Mon, 03 Mar 2008 Richard Duits wrote :
>
>> Hello Alexandre,
>>
>> I cannot find any limits in the datasheet/user manual of the LPC chips
>> and the RS485 tranceiver will go up to 12 Mbps. Those are the only
>> relevant components for this problem, so in theory the hardware should
>> support it. For 3 Mbps the UART will need a clock of 3 * 16 = 48 MHz,
>> which is the same as my PCLK.
>>
>> Regards,
>> Richard.
>> Alexandre Umino (Spin) wrote:
>>
>>> Does your hardware suport this baud rate?
>>>
>>> Spin
>>>
>>> 2008/3/3, Richard Duits :
>>>
>>>
>>>> Hallo All,
>>>>
>>>> I am trying to let two boards communicate over a RS485 link at 3
>>>> megabits per second. One board has a LPC2368 and the other has a
>>>> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
>>>> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
>>>> capable of 12 Mbps.
>>>>
>>>> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
>>>> transmission has a unacceptable number of errors (more than 1 per
>>>> second). When I let the LPC2368 communicate between UART1 and UART2 via
>>>> the RS485 tranceivers there are no errors up to 3 Mbps.
>>>>
>>>> Has anyone tried anything similar to this or do you have a suggestion
>>>> how to get the serial link (nearly) error free?
>>>>
>>>> Regards,
>>>> Richard Duits
>>>>
>>>>
>>>>
>>>>
Mike Harrison wrote:
> There is an issue on parts with fractional barudrate dividers, where you can set up a baudrate that
> works OK for transmit but receive is unreliable - you need to ensure that the PCLK divides to
> baud/16 exactly - you can get FDR combinations that appear to work out, and do function for
> transmission, but not for receive.
>
I am using PCLK / 1 (3 Mbps) as my baudrate clock the get the maximum
baudrate possible. PCLK / 2 (1.5 Mbps) and PCLK / 3 (1 Mbps) are also a
problem, but less than PCLK / 1.

> e.g. at 60MHz PCLK, you can't get exactly 1mbit (1m x16 does not go into 60 exactly) , but you can
> do 1.25M (1.25x16 , x3`) and 1.875. In principle you should be able to do 3.75 but not sure if
> this actually works.
> I've had 1.25M receive working reliably on a 2136/01 at 60MHz.
>
> With the clock rates you give above ( assuming PCLK is not being divided), 1,2 and 3mbits should be
> possible.
> At very high rates there may also be issues with things like input pin synchronisation delays,
> asymmetrical delay in teh driver and noise/jitter.
>
If clock noise because of the PLL or the lpc input pin is the problem,
then I don't see how I can solve this. When looking at the input of the
driver and the output of the receiver with a scope, I cannot find any
diffirence other than an expected delay.

> Also at high rates, the VIC unexpected interrupt issue starts to become more likely to occur - not a
> problem as long as you set the VIC unexpected int vector to return instead of reset ( some compiler
> examples default to the latter), and empty the rx fifo completely when you get an rx int.
>
> The issue is that you can get a rx timeout int, but more data then comes along so when it get
> serviced there is no apparent interrupt cause - this has been discussed here a few months ago.
>
>
I will take a close look at my interrupt routine to see if I can make
some improvements.
Regards,
Richard
On Tue, 04 Mar 2008 10:18:42 +0100, you wrote:

>Hello All,
>
>It seems that PCLK / 1 is to much to handle for the LPC microcontroller.
>I have set the fifo to generate an interrupt after receiving the first
>byte and I am counting how many bytes I read from the fifo each
>interrupt. With the baudrate clock set to PCLK / 1, the bytes come in
>faster than I can handle them, because the counter gives a maximum of 63
>bytes per interrupt. Which is way more than the 16 bytes the FIFO can
>hold. Not a big leap to conclude that I may be losing some bytes here.
>
>When I go back to a baudrate clock of PCLK / 2, the maximum number of
>received bytes per interrupt drops to 8. This is still a bit higher than
>I expected, but I will not lose any bytes at this rate. I still get some
>errors at this speed (ca. 1 in 100 packets of 1050 bytes), but this may
>be something I can handle by retransmitting.

You shouldn't have a problem receiving at 3mbaud with well written service code - assuming you set
the fifo trigger at 14 bytes, you should get an interrupt about every 46uS, i.e. about every 2200
instructions at 48MHz. Shouldn't take more than a couple of hundred instruction timess to service
the int.
However at this rate you probably want the serial interrupt to be a FIQ,and maybe write the service
code in assembler to maximise use of the dedicated FIQ banked registers. (Or at least use the
compiler;s maximum optimisation for the irq code and look at the output to check it's generating
sensible code)
>Thanks for your suggestions,
>Richard.
>Richard Duits wrote:
>> Hallo All,
>>
>> I am trying to let two boards communicate over a RS485 link at 3
>> megabits per second. One board has a LPC2368 and the other has a
>> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
>> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
>> capable of 12 Mbps.
>>
>> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
>> transmission has a unacceptable number of errors (more than 1 per
>> second). When I let the LPC2368 communicate between UART1 and UART2 via
>> the RS485 tranceivers there are no errors up to 3 Mbps.
>>
>> Has anyone tried anything similar to this or do you have a suggestion
>> how to get the serial link (nearly) error free?
>>
>> Regards,
>> Richard Duits
>>
>>
>
Hello All,

It seems that PCLK / 1 is to much to handle for the LPC microcontroller.
I have set the fifo to generate an interrupt after receiving the first
byte and I am counting how many bytes I read from the fifo each
interrupt. With the baudrate clock set to PCLK / 1, the bytes come in
faster than I can handle them, because the counter gives a maximum of 63
bytes per interrupt. Which is way more than the 16 bytes the FIFO can
hold. Not a big leap to conclude that I may be losing some bytes here.

When I go back to a baudrate clock of PCLK / 2, the maximum number of
received bytes per interrupt drops to 8. This is still a bit higher than
I expected, but I will not lose any bytes at this rate. I still get some
errors at this speed (ca. 1 in 100 packets of 1050 bytes), but this may
be something I can handle by retransmitting.

Thanks for your suggestions,
Richard.
Richard Duits wrote:
> Hallo All,
>
> I am trying to let two boards communicate over a RS485 link at 3
> megabits per second. One board has a LPC2368 and the other has a
> LPC2136/01. Both the LPC2368 and the LPC2136/01 have a 12 MHz crystal
> and are using the PLL to run at 48 MHz. The RS485 tranceivers are
> capable of 12 Mbps.
>
> Everything goes fine up to 500 kbps, but at 1 Mbps or higher the
> transmission has a unacceptable number of errors (more than 1 per
> second). When I let the LPC2368 communicate between UART1 and UART2 via
> the RS485 tranceivers there are no errors up to 3 Mbps.
>
> Has anyone tried anything similar to this or do you have a suggestion
> how to get the serial link (nearly) error free?
>
> Regards,
> Richard Duits
>
>