Requirement for circular shifting and inversion to make sense of RS-485 communications on ATSAME70-XPLD

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

We've connected our ATSAME70-XPLD to an RS-485 network.  We're using the ASF library to facilitate communications, drawing on the functions: usart_write() and usart_init_rs485(), reading is interrupt-driven.  We're using USART0 (PB1, PB0).

 

On the hardware front, we have 3 addressable devices.  Each one has selectable termination via a slider switch; these are all disabled (termination off).  NULLs frame transmissions from the devices (start with and end with)

 

We're observing meaningful communication, albeit circularly shifted and inverted.  As a temporary workaround, we've implemented a short routine to rectify the data.

 

We're unclear as to whether the ATSAME70-XPLD has a hardware RS-485 transceiver and wondered whether the inversion might arise from having a single transceiver between master and slave (assuming that the the slave devices employ hardware RS-485 transceivers, and that these invert the signal in a manner analogous to say a MAX232)

 

Any comments or suggestions are greatly appreciated.

This topic has a solution.
Last Edited: Sun. Mar 18, 2018 - 07:08 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The user manual for your board makes no mention of a rs485 transceiver. So, you need to add this externally.
What do you mean by ‘circular shifting and inversion’? This comment does not make sense to me.
RS485 data does not need to be inverted as does RS232.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lesperance wrote:
We're unclear as to whether the ATSAME70-XPLD has a hardware RS-485 transceiver

I see no claim that it does - neither on the product page, nor in the user manual - so why would you think that it did?

 

http://www.microchip.com/Develop...

 

Surely, looking at the schematic would clarify ?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you both for the comments.  I guess it's clear from your comments there is likely no hardware RS-485 transceiver on the ATSAME70 development board.  Installing an external transceiver is certainly possible.

 

In Atmel-11296D-ATARM-SAM E70-Datasheet_19-Jan-16.pdf we see the attached figure.  The text is not explicit about the requirement for an external driver, however, perhaps the driver schematic symbols between the USART and the bus make this requirement clear?

 

This is the code that does the rectification of each byte received

 

byte = ~byte; /* invert the byte */
byte = (byte >> 1) | (byte << 7); /* Right circular shift */

 

Without this rectification the data is repeatable, but non-sensical.  The only exception to this is when a NUL, meaning 0x00 or ‘\0’, is received, in this case the byte does not need to be inverted.
When this is applied to the input stream the data is as expected and has been tested for multiple different incoming data.

Switching A and B phases was attempted but no data was read, start and stop bits would get messed up.

Attachment(s): 

Last Edited: Sat. Feb 24, 2018 - 06:08 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The drawing shows the same70 usart and an external device.
Feeding an external RS485 signal may damage your board - you need a transceiver chip.

Enabling the rs485 feature on the usart is to use the RTS pin as the direction control for the rs485 transceiver.

Your code cannot solve a hardware problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kind thanks for the comments; we employed the DS1487N RS-485 transceiver with success.