# USB to Serial Converter Project 1.4

## Purpose

This application demonstrates how to use the Communication Device Class (CDC) to create a virtual COM port on a host computer. Such a device can be used as a bridge between legacy applications still using RS-232 ports, and computer without serial ports.

## Hardware Requirements

This package can be used with the following Atmel evaluation boards:

- AT91SAM7S-EK (except AT91SAM7S32)
- AT91SAM7X-EK
- AT91SAM7SE-EK
- AT91SAM9260-EK
- AT91SAM9263-EK
- AT91SAM9RL-EK
- AT91SAM9XE-EK
- AT91SAM9G20-EK

## Description

When the evaluation board is plugged to the host with a USB cable, it enumerates using the CDC class. The operating system may ask for a driver to install the device.

After the device is installed, a new serial port should become available. The data sent through this port is echoed on the USART of the device; Conversely, data received on the USART is forward to the USB host.

Here is a snapshot of the traces output by the application over the DBGU when it is working properly:

> `-- CDC serial driver example --
> CDCDSerialDriver_Initialize
> USBD_Init
> Conn Conn Hlr Res
> Hlr Res
> Hlr EoBRes CfgEpt0
> Hlr Susp
> Hlr Res
> Hlr EoBRes CfgEpt0
> Hlr Ept0 Stp NewReq Std gDesc Dev Write0(18)
> ...
> Hlr EoBRes CfgEpt0
> Hlr Ept0 Stp NewReq Std sAddr Write0(0)
> Hlr Ept0 Wr 0 EoT SetAddr(1)
> Hlr Ept0 Stp NewReq Std gDesc Dev Write0(18)
> ...
> Hlr Ept0 Stp NewReq Std gDesc Cfg Write0(9)
> ...
> Hlr Ept0 Stp NewReq Std gDesc Cfg Write0(67)
> ...
> Hlr Ept0 Stp NewReq Std gDesc Qua Stall0
> Hlr Ept0 Sta
> Hlr Ept0 Stp NewReq Std gDesc Str0 Write0(4)
> ...
> Hlr Ept0 Stp NewReq Std gDesc Str1 Write0(28)
> ...
> Hlr Ept0 Wr 4 EoT
> ...
> Hlr Ept0 Stp NewReq Std gDesc Str0 Write0(4)
> ...
> Hlr Ept0 Stp NewReq Std gDesc Str1 Write0(28)
> ...
> Hlr Ept0 Stp NewReq Std gDesc Dev Write0(18)
> ...
> Hlr Ept0 Stp NewReq Std gDesc Cfg Write0(67)
> ...
> Hlr Ept0 Stp NewReq Std sCfg SetCfg(1) CfgEpt3 CfgEpt1 CfgEpt2 Write0(0) Read1(4Hlr Ept0 Wr 0 EoT ConfigurationChanged
> 0) Hlr Ept0 Stp NewReq gLineCoding Write0(7)
> ...
> Hlr Ept0 Stp NewReq sControlLineState(0, 0) Write0(0)
> `

WARNING: on the SAM7X/XC evaluation kit, the project only works in internal flash.

## Usage

1. Build the application and download it inside the evaluation board. Please refer to the SAM-BA User Guide, the GNU-Based Software Development application note or to the IAR EWARM User Guide, depending on your chosen solution.
2. On the computer, open the DBGU port with a terminal application (e.g. HyperTerminal on Microsoft Windows).

- Settings: 115200 bauds, 8 bits, 1 stop bit, no parity, no flow control.

3. Start the application.
4. In the terminal window, the following text should appear:

> `-- USB Device CDC Serial Project 1.4 --`

5. Connect the USB cable to the board. Traces should start to appear on the terminal. Eventually, the operating system will report that a 'AT91USBSerial' device has been detected, and may ask for its driver.
6. If the host is running Microsoft Windows, the 6119.inf file must be provided during the installation of the device. It is located in the "/at91lib/usb/device/cdc-serial/drv" directory.
7. Once the device is properly configured, a new serial port should be appear on the host computer.
8. Disconnect the serial cable from the DBGU port of the board, and connect it to the USART port.
9. Open the virtual COM port in any terminal application. Data entered in the virtual COM port terminal should appear on the USART terminal, and vice-versa.

- Settings: 115200 bauds, 8 bits, 1 stop bit, no parity, no flow control.

###### Atmel Corporation ©2008