This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Sample code for interfacing LPC2478 with MSP430F5438A using RS485 is required

Other Parts Discussed in Thread: MSP430F5438A

Hi All,

I am working on a project in which, i am using MSP430F5438A and LPC2478 .

Have used RS485 to interface both device.

Now i need to program MSP430F5438A using LPC2478(Master).So regarding that i need some sample code.

Please send me the samples code for this project asap.

  • The basic RS485 communication is a simple UART communication. So sending and receiving bytes is exactly as done for a noremal RS232/UART transfer.
    The only difference is that RS485 is half-duplex. Only one peer can send at a time. If two try to send at the same time, the communication is corrupted (collision).

    The usual RS485 transceivers have control inputs for transmitter and receive, whcih can be controlled by the MSP. They are usually of opposite polarity, so only one GPIO pin is required to switch between listen and talk mode.

    The tricky part is to know when to listen and when to talk. It highly depends on application. Sometimes, you only want to listen and never send. Then you don't need any software control. Simply keep the receiver enabled and teh transmitte disabled (hardwired) and handle it as if there were just an incoming UART-RX signal.

    Sometimes there is a special token that tells the next one on the bus that he may speak now (polling or round-robin or token ring mechanisms).
    In some cases, the receiver is not disabled when the transmitter is on, so a peer just starts to talk and receives its own sending. In case of a collision this won't match and there can be a retry after some random waiting time.

    In our own setup, we use a time-slice mechanism. The master sends a synchronization packet, and all peers know that they have a time window of a few milliseconds staring a certain distance from the sync packet. (this also works well on RF, where I developed this originally for)

**Attention** This is a public forum