SAMV71 Xplained Ultra Software Package 1.5

USART Hardware Handshaking Example

Purpose

This example demonstrates the hardware handshaking mode (i.e. RTS/CTS) provided by the USART peripherals on SAMV7/E7 microcontrollers. The practical use of hardware handshaking is that it allows to stop transfer on the USART without losing any data in the process. This is very useful for applications that need to program slow memories for example.

Requirements

This package can be used with SAMV71 Xplained Ultra board or SAME70 Xplained board. It requires a fly some serial lines with hardware control support( TXD and RXD cross over, RTS and CTS cross over) to connect the PINs and PC. Connection: USART0 CTS0 (D39) USART0 RTS0 (D40) USART0 RXD0 (D14) USART0 TXD0 (D15)

Description

The provided program uses hardware handshaking mode to regulate the data rate of an incoming file transfer. A terminal application, such as hyper-terminal, is used to send a text file to the device (without any protocol such as X-modem). The device will enforce the configured bytes per second (bps) rate with its Request To Send (RTS) line.

Whenever the data rate meet or exceed the configurable threshold, the device stops receiving data on the USART. Since no buffer is provided to the XDMA, this will set the RTS line, telling the computer to stop sending data. Each second, the current data rate and total number of bytes received are displayed; the transfer is also restarted.

Note that the device may receive slightly less bytes than the actual file size, depending on the nature of the file. This does NOT mean that bytes have been lost: this is simply an issue with how line breaks are transmitted by the terminal. It is therefore better to use binary files, as they most often do not contain line breaks. For example, send one of the object files generated by the compiler.

Usage

  1. Build the program and download it inside the board. Please refer to the Getting Started with SAM V71/E70 Microcontrollers.pdf
  2. Connect a serial cable to a USART port on the evaluation kit.
  3. On the computer, open and configure a terminal application (e.g. HyperTerminal on Microsoft Windows) with these settings:
    • 115200 baud rates
    • 8 data bits
    • No parity
    • 1 stop bit
    • Hardware flow control (RTS/CTS)
  4. Start the application. The following traces shall appear on the debug terminal:
         -- USART Hardware Handshaking Example xxx --
         -- SAMxxxxx-xx
         -- Compiled: xxx xx xxxx xx:xx:xx --
         -I- Configure system tick to get 1ms tick period.
          -I- Please send a file to serial port (USART0)
         Total bytes received 0x0
    
  5. Send a file in text format to the device. On HyperTerminal, this is done by selecting "Transfer -> Send Text File" (this does not prevent you from sending binary files). The transfer will start and the device will update the bytes received counter on the terminal.
  6. Whenever the transfer is complete, the total number of bytes received should match the size of the sent file (unless it is a text file, see explanation in description section).

References

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines