6.1. Asynchronous serial communication
One bonus feature of the Pololu USB AVR Programmer v2 is the USB-to-TTL-serial adapter, which can be used for connecting microcontroller projects to a personal computer. The USB-to-TTL-serial adapter looks like a standard serial port to the operating system, allowing you to use existing terminal programs and software designed to use serial ports. This feature is similar to our CP2104 USB-to-Serial Adapter Carrier.
The TX and RX lines of the programmer are used to perform asynchronous serial communication. When the programmer receives a byte from the computer via USB, it will transmit that byte on the TX line. When the programmer receives a byte on the RX input line, it will send that byte back to the computer via USB.
The bytes are sent and received eight bits at a time, with the least significant bit first, with no parity and one stop bit. This coding is sometimes abbreviated 8N1. The bits must be non-inverted, meaning that a zero is sent as low voltage, and a one is sent as high voltage. All devices involved in asynchronous serial communication need to agree ahead of time on the duration of one bit (the baud rate), so all devices must be independently configured to run at the same baud rate before they will be able to communicate with each other. The programmer supports all integer baud rates from 300 to 115200 bits per second. The following figure is an example of an 8N1 TTL serial byte transmitted at 5 V:
To make a working serial connection between the programmer and another device, you should make sure to run the programmer at a voltage that is equal to or close to the voltage of the other device. The programmer’s voltage regulator controls what voltage it will be using, and the regulator settings are described in Section 7.
To use the USB-to-TTL-serial adapter, you must determine what port name the operating system has assigned it. You can look in the upper left corner of the Pololu USB AVR Programmer v2 Configuration Utility, or you can run
pavr2cmd --ttl-port, or you can follow the instructions in Section 4.5.
After determining the port name, you can use any serial port software to communicate on that port. There are many free terminal programs available, including PuTTY (Windows or Linux), Tera Term (Windows), Br@y Terminal (Windows), and screen (Linux or Mac OS X). Advanced users developing scripted applications might prefer the free terminal program kermit. To use any of these terminal programs with the USB-to-TTL-serial adapter, you must specify the port name determined above and your desired baud rate. The characters you type will be transmitted on the programmer’s TX line. Bytes received by the programmer on the RX line will be displayed on the screen by the terminal program.
If you need to send and receive non-ASCII bytes, you can use the Pololu Serial Transmitter Utility for Windows.
You can also write your own computer program to use the serial port. Windows, Linux, and Mac OS X all provide C APIs for serial port communication. The Microsoft .NET framework supports serial port communication with the System.IO.Ports.SerialPort class. The Qt framework provides the QSerialPort class. Java programs can use the RXTX library.