This example demonstrates the hardware handshaking mode (i.e. RTS/CTS) provided by the USART peripherals on AT91 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.
This example can be used on any AT91 evaluation kit, except when they do not provide an USART serial port (i.e. on AT91SAM9261-EK, AT91SAM7L-EK and AT91SAM7L-STK).
The provided program uses hardware handshaking mode to regulate the data rate of an incoming file transfer. A terminal application, such as hyperterminal, 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 PDC, 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.
The serial cables provided with AT91 evaluation kits CANNOT be used with this example, as RTS and CTS are not connected appropriately. Make sure that the RS-232 cable is a null-modem cable, with TXD <-> RXD and RTS <-> CTS.
-- Basic USART Hardware Handshaking Project 1.4 --
Bps: 0; Tot: 0