RS485 and Arduini

I succesfully started developing an RS485 bus between two Leonardos, using Softserial.
Transfering the RS4875 host to Arduino Due should be possible. Te Due houses 3 Uarts and I took care of the RTS "wire" . I see data coming in.
However: the data being received by the Leoardo using SoftSerial is different from the data being received by the Due. Where the code is running perfectly with the Leonardos, preceding the expected data the Due is receiving a 0 (zero), (then the expecrted data), followed by two times a zero (0).

Any ideas what is going wrong here?

There is an RS485 Mode selectable for USART, see Sam3x datasheet page 801.

As I wrote, I am receiving data.
See the applied settings below:
USART1->US_MR |= (1u << 0); //Set USART1 mode to RS485.
PIOA->PIO_ABSR |= (0u << 14); //Set PIOA14 to 0 => Choosing peripheral A = RTS for D23/PA14.
PIOA->PIO_PDR |= (1u << 14); //: Disables the PIO from controlling the corresponding pin (enables peripheral control of the pin).

Still I hadn't expect these leading and trailing zero's.

You should post ALL your code and not a part of it.

Anyway, your settings are uncorrect for RTS.

A simple test to play with RS485 upon a DUE is using USART0 and USART1 both in RS485 Mode with RS485 3.3V Transceivers and the code below:

/********************************************************************************/
/*                          USART RS485 Mode                                    */
/*                    Hook RX1 to TX2  and RX2 to TX1                           */
/********************************************************************************/

char c = 0;
void setup() {

  Serial.begin(250000);

  Serial1.begin(115200); // Serial1 is for USART0
  Serial2.begin(115200); // Serial2 is for USART1

  PIOB->PIO_PDR = PIO_PDR_P25;              // Set the GPIO to the peripheral for RTS0
  PIOB->PIO_ABSR |= PIO_PB25A_RTS0;
  USART0->US_MR |= US_MR_USART_MODE_RS485;  //select RS485
  USART0->US_TTGR = US_TTGR_TG(10);           //Select a Timeguard


  PIOA->PIO_PDR = PIO_PDR_P14;              // Set the GPIO to the peripheral for RTS1
  PIOA->PIO_ABSR |= PIO_PA14A_RTS1;
  USART1->US_MR |= US_MR_USART_MODE_RS485;
  USART0->US_TTGR = US_TTGR_TG(10);


  Serial2.print("Hello");
}


void loop() {
  String s;
  s.reserve(10);
  s = "";

  while (Serial1.available() > 0) {
    c = Serial1.read();
    s += c;

  }
  if (s.length() > 0) {
    Serial.println(s);
    Serial2.print(s);
  }
  delay(1000);
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.