Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USART RS485 Example with PDC
\par Purpose

The USART RS485 Example with PDC demonstrates how to use USART in RS485
mode.

\par Requirements

This package can be used with all SAM-EK boards. Before running, make sure
to connect two boards with RS485 lines. Match each paired pins of two
boards respectively with A to A, B to B and FGND to FGND.

Please refer to the board user guide for the details of RS485 jumper
settings.

\par Description

This example connects two boards through RS485 interface. One board acts
as the transmitter and the other one as the receiver. It is determined by
the sequence that the two applications started.

In any case, the application sends a sync character at running to seek a
receiver. If the acknowledgement is received in a short time, it will act
as the transmitter and then send a full frame text to the receiver.

The earlier started board will act automatically as the receiver due to no
acknowledgement received. The receiver will wait until sync character is
received. Then it sends the acknowledgement and waits for the full frame
sent by the transmitter. At the end of reception, it prints out message
through UART interface to assert that the whole process succeeds.

\par Usage

-# Build the program and download it into the two evaluation boards.
-# Connect a serial cable to the UART port for each evaluation kit.
-# On the computer, open and configure a terminal application for each board
   (e.g., HyperTerminal on Microsoft Windows) with these settings:
  - 115200 bauds
  - 8 bits of data
  - No parity
  - 1 stop bit
  - No flow control
-# Start application from two boards in sequence. Make sure the second board
   should NOT be started unless the first board has run to wait for the
   synchronizing character. The output message in later section would
   describe this.

-# In the terminal window, the following text should appear:
-- USART RS485 Example --
-- xxxxxx-xx
-- Compiled: xxx xx xxxx xx:xx:xx --
  1. The consequent messages will indicate the boards' behavior.
    • The earlier started board will output the message below to indicate it is waiting for a synchronization character:
      -I- Receiving sync character.
    • If it receives a sync character and prepare to receive a frame, it will print out the message below:
      -I- Start receiving!
    • After successfully receives a frame, the board will output the following message to indicate that the whole process succeeds.
      -I- Received successfully!
    • The later started one will act as transmitter, and if it receives an acknowledgement character successfully, it will output the following message and start transmitting:
      -I- Start transmitting!