You have no items in your shopping cart.

Subtotal: 0.00

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

GLCD (Graphical Liquid Crystal Display)

The Graphics LCD as the name suggests is a type of LCD which can display graphics. The graphical representation of any data presents good understanding than just characters. More user friendly applications can be designed by using the graphical LCDs.

Interfacing GLCD

Fig. 1 shows how to interface the GLCD to microcontroller. The 128X64 Graphical LCD interfaces to adjust contrast through trim pot. The GLCD 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), Page Select (CS).



Fig. 1 Interfacing GLCD to Microcontroller

 

Interfacing GLCD with 8051

We now want to display a text in 8051 Friendly Board by using GLCD module. The 8051 Primer board has numbers of GLCD connections, connected with I/O Port lines (P3.2, P3.3, P3.4 – P3.7 && P2.0 – P2.7) to make GLCD display.

Pin Assignment with 8051



 

GLCD/LCD

8051

LCD | 128x64 GLCD Selection

CONTROL L LINES

CS1

P3.2





CS2

P3.3

RS

P3.4

R/W

P3.5

E

P3.6

RST

P3.7

LCD – DATA LINES

DB0

P2.0

DB1

P2.1

DB2

P2.2

DB3

P2.3

DB4

P2.4

DB5

P2.5

DB6

P2.6

DB7

P2.7

 





Circuit Diagram to Interface GLCD with 8051





Source Code

The Interfacing GLCD with 8051 program is very simple and straight forward that display a text in 128 X 64 GLCD modules. Some delay is occurring when a single command / data is executed. In C programs you cannot be sure of delay, because it depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.

C Program to display a text in GLCD using 8051

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

Title : Program to GLCD display

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

#include 

#include 

#define DATA P2 sbit CS1 = P3^3;

sbit CS2 = P3^4;

sbit RS = P3^5;

sbit RW = P3^6;

sbit lcd_e = P3^7;

//sbit RST = P3^7;

void GLCD_PutPicture(const unsigned char *);

void Select_page(unsigned char);

int i;

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

//Load your black&white images here

//--------------------------------- code unsigned char const pan_bmp[1024] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,192,192,192,192,192,192,128, 0, 0, 0, 0, 0, 0,192,192,192, 0, 0, 0, 0, 0,192,192,128, 0, 0, 0, 0, 0,192,192, 0,192,192,192,192,192,192,192,192,192,192, 0, 192,192,192,192,192,192,192,192,192, 0, 0, 0,128,128,192,192, 192,192,192,128, 0, 0, 0,192,192, 0, 0, 0, 0, 0, 0,192, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255, 24, 24, 24, 24, 29, 15, 7, 0, 0,192, 248,127,103, 96,103,127,248,192, 0, 0,255,255, 3, 7, 28, 56, 224,192,255,255, 0, 0, 0, 0, 0,255,255, 0, 0, 0, 0, 0, 255,255, 24, 24, 24, 24, 24, 24, 24, 0, 0,126,255,129, 0, 0, 0, 0,129,195,129, 0, 0,255,255, 24, 24, 24, 24, 24, 24,255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 1, 0, 0, 0, 0, 0, 1, 3, 2, 0, 3, 3, 0, 0, 0, 0, 0, 1, 3, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 1, 1, 3, 3, 3, 3, 3, 1, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,112,248,204,204, 140,140,156, 56, 48, 0, 0,224,248, 24, 12, 12, 12, 12, 24,248, 224, 0, 0,252,252, 0, 0, 0, 0, 0, 0, 0, 0,252,252, 0, 0, 0, 0, 0, 0,252,252, 0, 12, 12, 12, 12,252,252, 12, 12, 12, 12, 0,252,252, 0, 0,224,248, 24, 12, 12, 12, 12, 24,248, 224, 0, 0,252,252, 56,112,192,128, 0, 0,252,252, 0, 0,112, 248,204,204,140,140,156, 56, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 28, 56, 49, 49, 49, 59, 31, 14, 0, 0, 7, 31, 24, 48, 48, 48, 48, 24, 31, 7, 0, 0, 63, 63, 48, 48, 48, 48, 48, 48, 0, 0, 15, 31, 56, 48, 48, 48, 48, 56, 31, 15, 0, 0, 0, 0, 0, 63, 63, 0, 0, 0, 0, 0, 63, 63, 0, 0, 7, 31, 24, 48, 48, 48, 48, 24, 31, 7, 0, 0, 63, 63, 0, 0, 1, 3, 14, 28, 63, 63, 0, 0, 12, 28, 56, 49, 49, 49, 59, 31, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 6,255,255, 0, 0,130,195, 97, 49, 31, 14, 0,238,255, 17, 17,255,238, 0,131,239,124, 56,124,239, 131, 0,252,254, 9, 9,251,242, 0, 96, 88, 70,255,255, 64, 0, 0, 0, 0,124,254,131, 1, 17,243,242, 0,255,255, 0, 0, 0, 0, 0,124,254,131, 1, 1,131,130, 0,255,255, 1, 1,131,254, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

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

// LCD Functions

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

void GLCD_Init(); void GLCD_Data(unsigned char);

void GLCD_Comd(unsigned char);

void DelayMs(int);

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

// LCD command Function

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

void GLCD_Comd(unsigned char cmnd)

{

DATA = cmnd;

//send command to port RS = 0;

//make it RS to Low RW = 0;

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

// LCD Data Function

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

void GLCD_Data(unsigned char dat)

{

DATA = dat;

//send command to port RS = 1;

//make it RS to high RW = 0;

//make it RW to low lcd_e = 1;

//enbale high DelayMs(10); lcd_e = 0;

//enbale low

}

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

// LCD Delay Function

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

void DelayMs(int k)

{

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

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

// GLCD Initialization Function

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

void GLCD_Init()

{

unsigned char Comd[5]={0xc0,0xb8,0x40,0x3f};

//LCD Command list Select_page(1);

//send commands to page1 for(i=0;i<4;i++)

GLCD_Comd(Comd[i]); Select_page(0);

//send commands to page0 for(i=0;i<4;i++)

GLCD_Comd(Comd[i]);

}

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

// Page Selection

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

void Select_page(unsigned char Page)

{

if(Page)

{

CS1=0;

//Page 0 LCD IC1 CS2=1;

}

else

{

CS1=1;

//Page 1 LCD IC2 CS2=0;

}

}

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

// Display Picture for page0 & page1

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

void GLCD_PutPicture(const unsigned char *ip)

//Change here for method 1,2 and 3

{

int Page=0,i=0;

int Column=0;

for (Page = 0;

Page < 8; Page++)

{

Select_page(1);

//Display part of image to Page1 GLCD_Comd(0xb8 | Page);

GLCD_Comd(0x40);

for (Column = 0;

Column < 128; Column++)

{

if (Column == 64)

{

Select_page(0);

//Display part of image to Page0 GLCD_Comd(0xb8 | Page);

GLCD_Comd(0x40);

}

GLCD_Data(*ip++);

}

}

}

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

// Main Program

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

void main(void)

{

DelayMs(2);

RST = 1;

DelayMs(5);

RST = 0;

DelayMs(5);

RST = 1;

DelayMs(5);

GLCD_Init();

//Initialize GLCD DelayMs(15);

GLCD_PutPicture(pan_bmp);

//Display Image while(1);

//wait forever

}