EmbeddedRelated.com
Forums
Memfault Beyond the Launch

How to use UART0 as LIN in LPC2378 ?

Started by Aji Pamungkas August 21, 2010
Hello, lpc2000 users.
i'm trying to use UART0 as LIN (TJA1020 chip) in LPC2378as master onMCB2300 board. I use flexdevel board as it's slave, using TH8082 as LIN transceiver and SCI in flexdevel.I initialize both of them using 9600 bps, 8 bit, 1 stop bit and no parity.In MCB2300, I use modified versionof UART APIby Martin Thomas .
Before using MCB2300, I use two FlexDevel board as a master and as a slave, and they work without any problem sending and receiving LIN message.
When i use UARTSend(0, (const BYTE*)0x31, 1) in MCB2300, the data that is received by SCI in FlexDevel board is not 0x31. If I use pin0-2 and pin 0-3 directly, no data ever transmitted. If I use UART1, a different data is received. My UART/LIN in MCB2300 is not able to receive anything.
I made two LIN board with the same chip (TJA1020), they have different schematic, but still FlexDevel receives the same data when i send 0x31 separately. So maybe the LIN boards that i made is ok.
I've been trying to solve this for days, it's time i have to ask you all, maybe i can find some answers here.
Is there something i have to do to change UART into LIN mode, let's say by changing some lpc2378 UART registers?Or... should I use GPIO pins directly ?If I have to use GPIO, should I make external serial board using MAX3232 chip ?Can I use UART in LPC2378 to send/receive LIN message, or should I use CAN or SPI instead ?I think it's because the UART break signal, LIN use 13 bits and UART use 11 bits (CMIIW), but how to change bit length in UART to 13 bits, can I change it ? or should i make software functions to handle this?
Thanks._,_._,___

An Engineer's Guide to the LPC2100 Series

On 08/21/2010 07:15 AM, Aji Pamungkas wrote:
> Hello, lpc2000 users.

When you start a new topic, please don't write a reply to an old thread.
Write a new message instead.

> i'm trying to use UART0 as LIN ...

I have not implemented LIN anywhere yet but anyway...

> Can I use UART in LPC2378 to send/receive LIN message, or should I
> use CAN or SPI instead ?

AFAICT, LIN have been designed to be implemented with standard UART
easily. Implementing it with CAN or SPI may be next to impossible.

> I think it's because the UART break signal, LIN use 13 bits and UART
> use 11 bits (CMIIW), but how to change bit length in UART to 13
> bits, can I change it ? or should i make software functions to
> handle this?

How do you try to send BREAK. Where do you expect that that 11-bit time
comes from? I think that you have to set BREAK signal and then count the
necessary 13-bit time yourself. Furthermore, I suspect, that, after you
release the BREAK, you must count at least one bit time before you send
the SYNC frame. Otherwise receivers can't tell properly where BREAK ends
and SYNC starts.

Can't you look at the signal with a scope and see what's going on?

--

Timo
Thanks Timo, i thought i pressed the right button to create a new topic, but now we can see that i was wrong. I'm creating a new one now. :D

--- In l..., Timo wrote:
>
> On 08/21/2010 07:15 AM, Aji Pamungkas wrote:
> > Hello, lpc2000 users.
>
> When you start a new topic, please don't write a reply to an old thread.
> Write a new message instead.
>
> > i'm trying to use UART0 as LIN ...
>
> I have not implemented LIN anywhere yet but anyway...
>
> > Can I use UART in LPC2378 to send/receive LIN message, or should I
> > use CAN or SPI instead ?
>
> AFAICT, LIN have been designed to be implemented with standard UART
> easily. Implementing it with CAN or SPI may be next to impossible.
>
> > I think it's because the UART break signal, LIN use 13 bits and UART
> > use 11 bits (CMIIW), but how to change bit length in UART to 13
> > bits, can I change it ? or should i make software functions to
> > handle this?
>
> How do you try to send BREAK. Where do you expect that that 11-bit time
> comes from? I think that you have to set BREAK signal and then count the
> necessary 13-bit time yourself. Furthermore, I suspect, that, after you
> release the BREAK, you must count at least one bit time before you send
> the SYNC frame. Otherwise receivers can't tell properly where BREAK ends
> and SYNC starts.
>
> Can't you look at the signal with a scope and see what's going on?
>
> --
>
> Timo
>


Memfault Beyond the Launch