You are currently viewing How to Interface UART with 8051 Development Board

How to Interface UART with 8051 Development Board

Spread the love

8051 Development Board

The 8051 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 serial port.

NXP’s 8051 (AT89V51RD2), 8051 Development board is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

UART

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 8051, we just need the basic signals.

Interfacing UART
Fig. 1 Interfacing UART to Microcontroller

Interfacing UART with 8051

We now want to display a text in PC from 8051 Development Board by using UART module. In 8051 Development Board contains two serial interfaces that are UART0 & UART1. Here we are using UART0. 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.

Pin Assignment with 8051

Circuit Diagram to Interface UART with 8051

Source Code

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

C Program to display a text in PC from 8051

*********************************************************************************************************

Title : Program to display a text in PC from 8051 through UART0

***********************************************************************************************************

#include  /* special function register declarations */

#include  /* prototype declarations for I/O functions */

void serial_init(void);

//-------------------------------------------------

//Setup the serial port for 9600 baud at 11.0592MHz.

//-------------------------------------------------

void serial_init(void)

{

SCON = 0x50;

/* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20;

/* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xFD;

/* TH1: reload value for 9600 baud @ 11.0592MHz*/ TR1 = 1;

/* TR1: timer 1 run */ TI = 1;

/* TI: set TI to send first char of UART */

}

//--------------------------

//Main Program Starts Here

//--------------------------

void main(void)

{

serial_init();

printf (" PS - PrimerC51 UART Demo\n\n\r");

while (1)

{

printf ("Hello World!! \n\r");

/* Print "Hello World" */

}

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.