Home > AVR Microcontroller Projects > Serial Interface for an AVR

Serial Port Interface for an AVR

This document describes how to add an serial interface to an AVR.

Most of the AVR devices have a serial port, often called UART or USART. But for interfacing with RS-232 devices, such as the COM port of a PC, a converter is necessary which converts the CMOS/TTL signals of the AVR to RS-232 compatible signals.

 

Variant 1: RS-232 / TTL Converter using +5V-Powered RS-232 Drivers/Receivers

starterkit-uart.gif (10251 bytes)

Parts List

1 +5V R232 Transceiver maxim integrated
MAX232A  or MAX3232CPE 
or equivalent
Datasheet (PDF)
Datasheet (PDF)
5 Ceramic Capacitor 100nF only old MAX232 need 1uF Tantalum Capacitors
1 DB9 Connector any  
1 Modem Serial cable (straight through) with DB9 Connectors any  

 

Variant 2: RS-232 / TTL Converter using MOSFET

This circuit shows a simple RS-232 to TTL interface level converter, which consists of two MOSFET transistors and two resistors. The only drawback is that this only generates 0V instead negative Voltage for RS232C logic '1'.  Most modern PC accept this level, even if it is not RS232C standard. The advantage of using MOSFET transistors instead bipolar ones, is that no current limiting resistor and clamping diode for negative voltage is needed to drive the gate. The optional resistor R3 improves ESD protection and prevents a floating input when the DB9 connector is not connected to a PC:

RS-232 Level Converter using MOSFET

 

Software

My UART library the AVR-GCC provides an easy interface to the UART.

 

Further Links

 

© Copyright 2002 Peter Fleury  http://tinyurl.com/peterfleury