You have no items in your shopping cart.

Subtotal: 0.00

How to Interface UART with AVR Development Board

AVR Development board

The AVR Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports In-system programming (ISP) which is done through Parallel/Printer port.

ATMEL’s AVR (Atmega8535), AVR Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.


UART (Universal Asynchronous Receiver Transmitter) are one of the basic interfaces which provide a cost effective simple and reliable communication between one controller to another controller or between a controller and PC.

RS-232 Level Converter

Usually all the digital ICs work on TTL or CMOS voltage levels which cannot be used to communicate over RS-232 protocol. So a voltage or level converter is needed which can convert TTL to RS232 and RS232 to TTL voltage levels. The most commonly used RS-232 level converter is MAX232.

This IC includes charge pump which can generate RS232 voltage levels (-10V and +10V) from 5V power supply. It also includes two receiver and two transmitters and is capable of full-duplex UART/USART communication.

  • RS-232 communication enables point-to-point data transfer. It is commonly used in data acquisition applications, for the transfer of data between the microcontroller and a PC.
  • The voltage levels of a microcontroller and PC are not directly compatible with those of RS-232, a level transition buffer such as MAX232 be used.

Interfacing UART

Fig. 1 shows how to interface the UART to microcontroller. To communicate over UART or USART, we just need three basic signals which are namely, RXD (receive), TXD (transmit), GND (common ground). So to interface UART with AVR Atmega8535, we just need the basic signals.

Fig. 1 Interfacing UART to Microcontroller


Interfacing UART with AVR Development

We now want to display a text in PC from AVR Development board by using UART module. In AVR Development board contains a single serial interface that is UART. The Transmitter pins send the data into PC and the receiver pin receives the data from PC. The PC and microcontroller speed are denoted by using baud rate. When the baud rates of both PC and Microcontroller are same, then only the data transmit and receive correctly otherwise not. The TXD (PORTD.1) & RXD (PORTD.0) pins are used to data transmit or receive operation.

Pin Assignment with AVR Development board







Connect Serial cable between USART Section in the Board and PC. Open HyperTerminal

Press RESET Once (If Necessary)

Type a character, “Hello

World” string will be re-

turned from Board.




Circuit Diagram to Interface UART with AVR Development

Source Code

The Interfacing UART with AVR program is very simple and straight forward, which display a text in PC from AVR Development board through UART. Some delay is occurring when a single data is sent to PC. C programs are written in CodeVisionAVR. The baud rate of microcontroller is 9600.

C Program to display a text in PC from AVR


Title : Program to display a text in PC from AVR through UART




unsigned char RecDat;

unsigned char TxDat[]="Hello World";

#define FOSC 16000000L //Oscillator Frequency 16Mhz

#define USART_Baud 9600

#define BaudH ((unsigned int)(((FOSC/16/USART_Baud)-1) >> 8))

#define BaudL ((unsigned int)(((FOSC/16/USART_Baud)-1) & 0xFF))

void Serial_init(void);

void Putstr(unsigned char *);

void Transmit(unsigned char);

unsigned char Receive(void);

void main()












void Serial_init()


UCSRA = 0x00;

//Status Register UCSRB = 0x18;

//Transmit Enable,Receive enable,interrupts disabled UCSRC = 0x86;

//8 databits,no parity,single stop UBRRH = BaudH;

UBRRL = BaudL;


void Putstr(unsigned char *string)


while(*string) Transmit(*string++);


void Transmit(unsigned char Data)



UDR = Data;


unsigned char Receive()



return UDR;


To compile the above C code you need the CodeVision AVR software. The software has it’s own IDE and built-in AVR gcc- Compiler. They must be properly installed and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In CodeVision AVR software, you can develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without microcontroller Board.

The AVR Code Blaster software is used to download the hex file into your microcontroller through Parallel port.

Testing the UART with AVR

Give +12V power supply to AVR Development board; the serial cable is connected between the AVR Development board and PC. Open the Hyper Terminal screen, select which port you are using and set the default settings. Now the screen should show some text messages.

If you are not reading any text from UART, then you just check the jumper connections & just check the serial cable is working. Otherwise you just check the code with debugging mode in CodeVisionAVR.

General Information

  • For proper working use the components of exact values as shown in Circuit file.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.
  • Use the exact value crystal shown in schematic.
  • More instructions are available in following articles,

User Manual for ATMEGA Development Kit

How to create & Debug a Project in CodeVision AVR.