This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Questions about half duplex RS485 Network

I am currently working on the half duplex RS485 Network related stuff.

It seems that, the most popular implementation is to use the 9th-Bit (Parity Bit)
as an identifier to identify the Address-bytes and Data-bytes.

For most micro-controllers, they do support such a mechanism, for example AT91SAM7Sxxx.

According to the AT91SAM7S Series Preliminary:
31.6.3.6 Multidrop Mode
This mode differentiates the data characters and the address characters. Data is
transmitted with the parity bit at 0 and addresses are transmitted with the parity bit at 1.
31.6.6 RS485 Mode
The USART features the RS485 mode to enable line driver control. The behavior of the RTS pin is controlled by the TXEMPTY bit.

# SENDA: Send Address
0: No effect.
1: In Multidrop Mode only, the next character written to the US_THR is sent with
the address bit set.

# PARE: Parity Error Interrupt Enable

What software needs to do:

For Master/Transmitter
1. Set 'Multidrop Mode' on
2. Set SENDA bit
3. Send an Address-byte
4. Send the Data-bytes

For Master/Receiver
General half duplex Receiver

For Slave/Transmitter
General half duplex Transmitter

For Slave/Receiver
1. Interrupted by a 'Parity Error Interrupt', check the Address-byte.
2. If the Address-byte is correct, receive the following Data-bytes.

Unfortunately, LPC2xxx does not support such a mechanism;
so I will have to implement it by software:

For Master/Transmitter
1. Poll UART Line Status Register to see if 'Transmitter Empty' is true.
2. Turn off the UART FIFO.
3. Set 'Forced "1" stick parity' and enable it in UART Line Control Register.
4. Send an Address-byte.
5. Poll UART Line Status Register to see if 'Transmitter Empty' is true.
6. Disable 'parity generation and checking' in UART Line Control Register.
7. Turn on the UART FIFO.
8. Send the Data-bytes.

For Master/Receiver
General half duplex Receiver.

For Slave/Transmitter
General half duplex Transmitter.

For Slave/Receiver
1. Interrupted by every incoming bytes, check if 'Parity Error' happens.
2. If 'Parity Error' happens, check the Address-byte.
3. If the Address-byte is correct, receive the following Data-bytes.

In the olden days, the micro-controllers were not very powerful, so we had to reduce
the communication load. But for now, LPC2xxx is a 32bits micro-controller, usually
running on 48MHz, I think it is powerful enough. And if my understanding is correct
(not confident), I don't see any communication load reduction with LPC2xxx and 9th-Bit
mechanism.

Thus, is it a good idea, to use a packet instead of a byte? maybe 140 bytes or
1524 bytes for a packet, including both address and data. (SMS message or Ethernet packet)
Though our system requirement is not well defined. I believe the communication load will
not be heavy, maybe several kilo-bytes a day. If this is a practicable idea, then how can
I implement it? I am not smart, so it is better to follow a existing small protocol,
but I almost don't know anything about network protocols, which one should I choose?

Please correct me and give me some hints. Many thanks in advance.