Spread the love

Interfacing of Graphical LCD with LPC2148.

This project illustrates how to interface a Graphical LCD with LPC2148 .

GRAPHICAL LCD :-

Graphical LCD pin diagram

The 16×2 Character LCDs have their own limitations; they can only display characters of certain dimensions. The Graphical LCDs are thus used to display customized characters and images. The Graphical LCDs find use in many applications; they are used in video games, mobile phones, lifts etc. as display units.

Various graphical LCDs are available in the market with different sizes. Here JHD12864E Graphical LCD has been explained. This LCD has a display format of 128×64 dots and has yellow-green colour backlight. Each LCD needs a controller to execute its internal operations. This LCD uses two KS0108 controllers.

The 128×64 LCD is divided into two equal halves with each half being controlled by a separate KS0108 controller. Such LCDs (using KS0108 controller) involve paging scheme, i.e., whole LCD is divided equally into pages. The paging scheme of the graphical LCD can be easily understood from the following table.

PIN DESCRIPTION :

pin

CIRCUIT DIAGRAM :

glcd

CODE FOR PROJECT :

GraphicalLcd.c –

#include<lpc21xx.h>
#include"delay.h"
#include"graphical_lcd.h"
void pic(const unsigned char *ip);
char txt[]={0x80,0xfd,0xfb,0xf7,0xfb,0xfd,0x80,0xff};
const unsigned char mnb[1024] = {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128,   0,  64, 128,   0,  98,  68,   8,  16,   0, 128,  72, 132,   0,   0,  96,  32,   0, 192,  64,   0, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128,  16, 132, 121,   4,   3,   1, 128,   0,   0,   0,   0,   0,   0,   0,  24,  23,  16,   0,   0,   0,  32,  32,  64, 128, 128,   1,  34, 156, 112, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128,   0,  64, 192,   0,  96,  64,  16,  64,  96,  32, 128,  64,   0, 128,   0,   0,   0,   0,   0,   0,  32,  16,   0,   0,   0,   4,   0,   0,   0,   3,   0,   3,   0,   4,   4,   6,   8,  16, 112, 192,   0,   0,   0,   0,   0,   0,   0,   0, 128,  32,   0,   0,   8,   1,   7,   6,   4,   6,   4,   7,   4,   4,   0,   8,   8,  16, 112, 192,   0,   0,   0,   0,   0,   0,   0,   0, 240,   0,   0, 122, 122,   0,  64,   0,   2,   0,   4, 248,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0, 128, 128,   0,  64, 128,   0,  96, 128,  48,  96,  24,  24,  32,  12,  20,  18,   6,  12,   3,   7,   4,   3,   3,  26,   1,  31, 125,  60,  60,  60, 125,  25,   6,   2,   3,   5,   4,   2,   9,  12,   6,  18,  10,  36,  48,  64,  96,  48, 192, 192,  32, 160, 192,  64,  16, 144,   0,   8,   8,   4,   6,   1,   0,   0,   0,   0,   0,   0,   0,   0,   1,   0,   0,   0,   0,   0,   0,   0,  32,  32,  32,  32,  32,   0,  16,  16,   8,  12,   6,   3, 128, 128, 128,   0,   0, 192, 192, 128, 255,   0,   0,   7,  69,   8, 192, 135,   0,   0, 128, 255,   8, 224, 240, 240, 224, 192, 192, 128,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   1,   1,   1, 129,   1,  63,  33,  33,  33,  33, 123,  63,  37,  37,  37,  63, 187,  33,  33,  33,  57,  37,  35, 163,  39,  47,  61,  57,  49,  33,  35,  63,  39,  37,  45,  57,  57,  63,  63,  33,  33,  59, 127,  63,  37,  37,  37,  47,  59,  57,  49, 225,  33,  33,  33,  33,  63,  33,   1, 192,   0, 224,  32,  32,   0,   0,   0,  48,  48,  32,   0, 136, 152, 152,  16, 128, 140,  76,  72,  64,   0, 198, 230,  36,  32,   0,   3, 227, 242,  16,  16,   1,   1,   9, 248, 248,   0,   0,   4, 255,   0,   0, 141, 136, 152, 144,  61,   1,   0, 218, 255,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 252, 252, 248, 
  0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   0,   0,   0, 255,  86,   0,   0,   0,   0, 255,   0,   0,   0,   0, 255, 255,  16, 172, 244,  62,  37,  39,  35,  34,  34, 226,  34,  34,  34,  35,  37,  38,  58, 228, 248,   0, 255, 255,   0,   0,   0, 255, 255,   0,   0, 255,   0,   0,   0,   0,   0,   0,   0,   0, 255,   2,   0,   0, 127,  65,  65,   0,  63,  63,   0,   0,  32,  32,  63,  63,   0, 128, 128, 128, 159, 159, 144, 144, 128, 128, 143, 143, 136,   8,  72,  72,  64, 199,  71, 192, 192,   4,  15,   0,  16,   5,  33,  34,  38,  32,  48,   0,  15,   6,   0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
  0,   0,   0,   0,   0,   0,  64,  64, 127,  64,  64,  64,  64, 127, 107,  64,  64,  64,  64, 127,  64,  64,  64,  64, 127, 127,  64,  84, 127,  64,  64,  64,  64,  64,  64, 127,  64,  64,  64,  64,  64,  64,  64, 127, 127,  64, 127, 127,  64,  64,  64, 127, 127,  64,  64, 127,  64,  64,  64,  64,  64,  64,  64, 240, 255,   0,   0,   0,   0,   1,   1,   1,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,  64, 255, 255,   0,  16,  16,  16,  16,  16,  16,  16, 255,   0, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,  63, 255,  15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 
  0,   0,   0,   0,   0,   0,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   6,   0,   0,   0,   0,   0,  63,  43,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  47,  32,  63,  63,  32,  32,  32,  32,  32,  32,  32,  32,  63,  32,  47,  47,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  40,  63,  32,  32,  32,  47,  63,  47,  47,  63,  63,  63,  63,  63

};





int main()
{
	 int i;
	 char x;
	PINSEL0=0X00000000;
	PINSEL1=0X00000000;
	IO0DIR=0XFFFFFFFF;
  lcd_ini();
	pic(mnb);
	
	while(1);
}


void pic(const unsigned char *ip) 
{
    int Page=0,i=0;
    int Column=0;
       for (Page = 0; Page < 8; Page++)      
    {
         page_sel(1);                        
         cmd(0xb8 | Page);
         cmd(0x40);
                  for (Column = 0; Column < 128; Column++)
         {
             if (Column == 64)
            { 
                 page_sel(0);                  
                 cmd(0xb8 | Page);
                   cmd(0x40); 
            }
             lcd_display(*ip++);                          
        }
    }
}

GraphicalLCD.h – 

#define LCD (0xff<<8)
#define RS (1<<16)
#define RW (1<<17)
#define EN (1<<18)
#define CS1 (1<<19)
#define CS2 (1<<20)
#define RST (1<<21)
void lcd_display(unsigned int x)
{
 IO0CLR|=(RS|RW|EN|LCD);
 IO0SET|=(x<<8);
 IO0SET|=RS;
 IO0CLR|=RW;
 IO0SET|=EN;
 delay_fv(10,10);
 IO0CLR|=EN;
	delay_fv(10,10);
}

void cmd(unsigned char m)
{
	IO0CLR|=(RS|RW|EN|LCD);
 IO0SET|=(m<<8);
 IO0CLR|=RS;
 IO0CLR|=RW;
 IO0SET|=EN;
 delay_fv(10,10);
 IO0CLR|=EN;
	delay_fv(10,10);
}

void page_sel(int a)
{
	IO0CLR|=(CS1|CS2);
	if(a)   //PAGE 0
	{
		IO0CLR|=CS1;
		IO0SET|=CS2;
  }
	else   // PAGE 1
	{
		IO0CLR|=CS2;
		IO0SET|=CS1;
  }
}
void lcd_ini()
{
	IO0SET|=RST;
	page_sel(1);
  cmd(0Xb8);
  cmd(0X40);
	
  //cmd(0X3F);
	page_sel(0);
  cmd(0Xb8);
  cmd(0X40);
  //cmd(0X3f);
}


void lcd_str(unsigned char *str)
{
while(*str!='\0')
{
lcd_display(*str);
str++;
}
}

COMING SOON ………………….

video