EmbeddedRelated.com
Forums
Memfault Beyond the Launch

RS-485 direction switching with LPC2138/2148

Started by tilmannreh August 26, 2010
--- In l..., Herbert Demmel wrote:

> the trick I did in my program is as follows (only works, if you do not
> use parity usually): setup the parity as well and stick it to the
> polarity of the stop bit (1 is suppose) and set the UART to 9 bit, then
> you can use one of the flags indicating the FIFO is empty (don't
> remember which one) giving you the exact time when you have to change
> the direction.

Thanks, that is a very useful hint. I just tried and set "mark"
parity only for the last transmitted byte. Then, this fake parity bit
is actively sent before THRE is set, resulting in switching the
transmitter off. After that, the UART is configured back to "no
parity".

Since this is only half duplex communication, it works fine - without
additional timers.

> The only disadvantage is, that you have to use 9 bits on your PC
> (sending to the LPC21xx) as well, otherwise you would get invalid
> characters on receiving on the LPC.

Since I now turn on "fake parity" only for the last transmitted
character, the rest of the communication doesn't suffer from it.

Many thanks,
Tilmann

An Engineer's Guide to the LPC2100 Series


Memfault Beyond the Launch