RS485 Half Duplex

Discussion to talk about software related topics only.
Post Reply
BryanJS
Posts: 7
Joined: Sun Jun 03, 2018 10:14 am

RS485 Half Duplex

Post by BryanJS »

I am using a Mod5234 , Uart 1 and using it for a Modbus RS485 ( Half Duplex ) communications.

The Uart_RX , Uart_Tx and Uart_RTS are controlling a SN65HVD1780 chip. I can see the data is been TX but the RX data is low. This is because the RTS Line just remains high.

How do I control the RTS line. The command SerialEnableHwTxFlow(MB_MASTER_PORT,1); just seem to disable the coms

I am using interrupt based comms ...


ComsStatus = WAITING; // Clear the coms state
MessageCounter = 0 ; // Initialize the message counter
pReceiveTimer = &pCounters->MB_ReceiveTimer; // Get the reference to the receive timer
pMBService= new Modbus(); // Create the Modbus Service class

pRxBuffer = (BYTE *) malloc(MB_BUF_SIZE); // Allocate the RX buffer
pTxBuffer = (BYTE *) malloc(MB_BUF_SIZE); // Allocate the TX buffer

// Open the port
SerialClose(MB_MASTER_PORT);

SerialEnableHwTxFlow(MB_MASTER_PORT,1);
OpenSerial(MB_MASTER_PORT, MB_BAUD,1,8,eParityNone);



UartData[MB_MASTER_PORT].m_pPutCharFunc = MasterReceiveCallback; // Set the receiver callback
UartData[MB_MASTER_PORT].m_pGetCharFunc = MasterTransmitCallback; // Set the transmiter callback

iBytesReceived = 0 ;
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: RS485 Half Duplex

Post by pbreed »

For 485 you want the function:
void Serial485HalfDupMode( int port, int enab );

If your using SN65HVD1780
The Driver input is active high the RTS line on the 5234 is active low.
You need an inverter...

Also
Why are you using your own buffers rather than the standard serial interface?
Post Reply