You have no items in your shopping cart.

Subtotal: 0.00

How to Interface LCD with 8051 Advanced Development Board

8051 Advanced Development board

The 8051 Advanced 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 Slicker Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

LCD (Liquid Crystal Display)

Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. A liquid crystal display (LCD) is a flat panel display that uses the light modulating properties of liquid crystals (LCs). LCD Modules can present textual information to user.

Interfacing LCD

Fig. 1 shows how to interface the LCD to microcontroller. The 2x16 character LCD interface card with supports both modes 4-bit and 8-bit interface, and also facility to adjust contrast through trim pot. In 8-bit interface 11 lines needed to create 8-bit interface; 8 data bits (D0 – D7), three control lines, address bit (RS), read/write bit (R/W) and control signal (E).



Fig. 1 Interfacing 4 bit LCD to Microcontrolle

 

Interfacing 8 bit LCD with 8051

We now want to display a text in 8051 Advanced Development board by using 8 bit LCD module. The 8051 Slicker board has seven numbers of LCD connections are needed to create 4-bit interface; connected with 8 data bits (P1.0 – P1.7, D0-D7), address bit (RS-P3.5), read/write bit (R/W-P3.6) and control signal (E-P3.7) to make LCD display.

Pin Assignment with 8051



 

LCD MODULE

8051 LINES

2x16 LCD Selection

CONTROL

RS

P3.5





RW

P3.6

E

P3.7

DATA LINES

D0

P1.0

D1

P1.1

D2

P1.2

D3

P1.3

D4

P1.4

D5

P1.5

D6

P1.6

D7

P1.7

 

Make switch SW31 to ‘LCD’ label marking position





 



Circuit Diagram to Interface 8 bit LCD with 8051





Source Code

The Interfacing 8 bit LCD with 8051 program is very simple and straight forward, which display a text in 2 X 16 LCD module using 8 data lines only. Some delay is occurring when a single command / data is executed.

C Program to display a text in 8 bit LCD using 8051

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

Title : Program to 8 bit LCD display

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

#include 

//Define 8051 Registers

#include 

//Define I/O Functions

#define DATA P1

//Define DATA to Port2

//Define control pins sbit RS = P3^5;

//Register Select sbit RW = P3^6;

//LCD Read/Write sbit lcd_e = P3^7;

//LCD Enable code unsigned char msg[] = (" 8051 ADVANCED ");

//Display the message code unsigned char msg1[] = (" DEVELOP BOARD ");

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

// LCD Functions

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

void lcd_init(void);

void lcd_cmd(unsigned char);

void lcd_display(unsigned char);

void DelayMs(int);

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

// LCD command Function

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

void lcd_cmd(unsigned char cmnd)

{

DATA = cmnd;

RS = 0;

RW = 0;

lcd_e = 1;

DelayMs(35);

lcd_e = 0;

}

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

// LCD Data Function

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

void lcd_display(unsigned char dat)

{

DATA = dat;

RS = 1;

RW = 0;

lcd_e = 1;

DelayMs(35);

lcd_e = 0;

}

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

// LCD Delay Function

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

void DelayMs(int k)

{

unsigned int a;

for(a=0;a<=k;a++);

}

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

// LCD Initialization

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

void lcd_init(void)

{

unsigned char i;

lcd_cmd(0x38);

//2x16 Character 5x7 dot DelayMs(15);

//matrix LCD,8-bit format lcd_cmd(0x0c);

//Display On, cursor off DelayMs(15);

lcd_cmd(0x06);

//Shift Cursor to right DelayMs(15);

lcd_cmd(0x01);

//Clear display screen DelayMs(15);

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

// First Line Message Display

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

lcd_cmd(0x80);

//First Line Initialization DelayMs(35);

i=0;

while(msg[i]!='\0')

{

lcd_display(msg[i]);

i++;

}

DelayMs(50);

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

// Second Line Message Display

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

lcd_cmd(0xc0);

//Second Line Initialization DelayMs(35);

i=0;

while(msg1[i]!='\0')

{

lcd_display(msg1[i]); i++;

}

DelayMs(50);

}

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

// LCD Main Program

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

void main(void)

{

lcd_init();

//LCD Initialization DelayMs(1);

DelayMs(1);

while(1);

//Loop Forever

}