Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] problem in interfacing graphical LCD using LPC2138

Status
Not open for further replies.

abhishekdixit

Full Member level 2
Joined
Dec 30, 2011
Messages
124
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
India
Activity points
2,182
hello,
i am interfacing graphical LCD with LPC2138 micro controller. but their is a some problem genrating in my code, due to this i am unable to interface my LCD. I am attaching my code & proteus file with this post.
please help me to remove my problem..
Code:
#include<LPC213X.H>
#define RST 4
#define E 5
#define RW 6
#define DI 7
#define CS1	8
#define CS2	9
#define LED 18

void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
void lcd_inilize();
void shift(int);
void delay(unsigned int);
void display();
void page_address(int);
void column_address(int);
void left_side(int,char);
void right_side(int,char);
void clear_screen();		
void start_line(int);

/*const unsigned char truck[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,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   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, 128, 128, 128, 128,  64,  64,  64,  64,  64,  64,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32, 160, 160, 160,  96, 224, 224,  96,  96,  96,  32,   0,  32,  32,  32,  32,  32,  32,  32,  32,  32,   0,   0,  64,  64,  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, 254,   0,   1,   1,   1,   1,   1, 253, 253, 253, 253,   1,   1,   1,   1,   1,   1, 253, 253, 253, 253,   1,   1,   1,   1, 253, 253, 253, 253, 249, 241, 225, 193, 129, 193, 225, 249, 253, 253, 253, 253, 253,   1,   1,   1,   1, 253, 253, 253, 253, 221, 221, 221,  29,  17,   1, 255,   1,   1,   1,   1,   0, 254,   1, 168,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,   8,  16, 224,  24,  36, 132,   0,   2, 130,   5,  81,  68, 112, 160, 192,  96,  96,  32,   0, 128, 128, 192, 192, 192,  64,   0,   0,   0,   0,   0, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,  63,  96,  96,  96, 224,  96,  96, 127, 127, 127, 127, 124, 124, 124, 124,  96,  96, 127, 127, 127, 127,  96,  96,  96,  96, 127, 127, 127, 127,  97, 103, 111, 127, 127, 111, 103,  99,  97, 127, 127, 127, 127,  96,  96,  96,  96, 127, 127, 127, 127, 125, 125, 125, 124, 116,  96, 127,  64,  64,  64, 160,  96, 252, 246,   1,  14,   6,   6,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,  66, 114,  60,  32,  16,  16,   0,   4,   2,   3,   2,   0,   0,   0,   4,   4,   4,   4,  20,  16,  16,  16,  16,  16,   9,   9,  41, 112,  32,  67,   5, 240, 126, 174, 128,  56,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   0,   0,   0,   0,   0,   0,   1,   1,   1,   1,   1,   1,   1,   1,   1, 127, 127, 127, 127, 255, 255, 247, 251, 123, 191,  95,  93, 125, 189, 189,  63,  93,  89, 177, 115, 243, 229, 207,  27,  63, 119, 255, 207, 191, 255, 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 127, 127, 127, 127, 255, 255, 255, 127, 127, 125, 120, 120, 120, 120, 120, 248, 120, 120, 120, 120, 120, 120, 248, 248, 224, 135,   0,   0,   0,   0,   0,   0,   0,   0, 128, 240, 248, 120, 188, 220,  92, 252,  28,  28,  60,  92,  92,  60, 120, 248, 248,  96, 192, 143, 168, 216, 136,  49,  68,  72,   2, 160,  96,   0,   0,   0,   0,   0,   0, 
  0,   0,   0, 128, 192, 248, 248, 248, 248, 252, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 246, 239, 208, 246, 174, 173, 169, 128, 209, 208, 224, 247, 249, 255, 255, 252, 220, 240, 127, 255, 223, 255, 255, 255, 255, 255, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 254, 255, 190, 255, 255, 253, 240, 239, 221, 223, 254, 168, 136, 170, 196, 208, 228, 230, 248, 127, 126, 156, 216, 224, 240, 240, 242, 242, 240, 177,  32,   0,   0,   0,   0,   0,   0,   0, 
  0,   0,   0,   1,   1,   1,   1,   3,   3,   3,   7,   7,   7,   7,   7,  15,  15,  15,   7,  15,  15,  15,   7,   7,  15,  14,  15,  13,  15,  47,  43,  43,  43,  43,  43,  47, 111, 239, 255, 253, 253, 255, 254, 255, 255, 255, 255, 255, 191, 191, 239, 239, 239, 191, 255, 191, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127, 127, 127, 127, 255, 255, 191, 191, 191, 191, 255, 254, 255, 253, 255, 255, 255, 251, 255, 255, 255, 127, 125,  63,  31,  31,  31,  31,  31,  31,  63,  15,  15,   7,   7,   3,   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,   0,   0,   0,   0,   0,   0,   0,   0,   1,   1,   0,   1,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   1,   1,   1,   1,   1,   1,   1,   1,   3,   3,   3,  11,  11,  11,  11,   7,   3,  14,   6,   6,   6,   2,  18,  19,  19,   3,  23,  21,  21,  17,   1,  19,  19,   3,   6,   6,  14,  15,  15,   7,  15,  15,  15,  11,   2,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
};*/

void display()
{
	IOCLR0|=1<<DI;
	IOCLR0|=1<<RW;
	lcd_data(0x3E);
	delay(100);
	lcd_data(0x3F);
}

void lcd_initilize()
{	 
     display();
	 IOSET0|=1<<RST;
	 IOCLR0|=1<<E;
	 IOCLR0|=1<<CS1;
	 IOCLR0|=1<<CS2;	
}

void page_address(int i)
{
	int k;
	IOCLR0|=1<<DI;
	IOCLR0|=1<<RW;
	k=(0x0b8|i);
	lcd_cmd(k);
	delay(100);
}

void column_address(int i)
{
	int k;
	IOCLR0|=1<<DI;
	IOCLR0|=1<<RW;
	k=(0x40|i);
	lcd_cmd(k);
	delay(100);
}

void left_side (int i,char value)
{
	unsigned int a;
	IOSET0|=1<<CS2;
	IOCLR0|=1<<CS1;

	for(a=0;a<i;a++)
	{
		lcd_data(value);
		delay(100);
	}
}

void right_side(int i,char value)
{
    unsigned int a;
	 IOCLR0|=1<<CS2;
	 IOSET0|=1<<CS1;
	 for(a=0;a<i;a++)
	 {

		 lcd_data(value);
		 delay(100);
	 }

 }

void start_line(int i)
{
 	IOCLR0|=1<<CS1;
	IOCLR0|=1<<CS2;
	lcd_cmd(i);
	delay(100);
}

void lcd_cmd(unsigned char value)
{
	IOCLR0|=1<<DI;
	delay(7);
	IOCLR0|=1<<RW;
	delay(7);
	shift(value);
	delay(100);
	IOSET0|=1<<E;
	delay(100);
	IOCLR0|=1<<E;
 }
						   
 void lcd_data(unsigned char value)
 {
 	IOSET0|=1<<DI;
	delay(7);
	IOCLR0|=1<<RW;
	delay(7);
	shift(value);
	delay(7);
	IOSET0|=1<<E;
	delay(7);
	IOCLR0|=1<<E;
 }

void shift(int value1)
{
	unsigned int j;
	for(j=0;j<8;j++)
	{
		if(value1 & 0x01)
		{		  
			IOSET0|=1<<(j+10);
		}
		else
		{
			IOCLR0|=1<<(j+10);
		}
		value1=value1>>1;
	
	 }
}

void delay(unsigned int a)
{	unsigned int i;
   for(i=0;i<a;i++)
   {
	T0MR0= 3000;
	T0MCR= 0x04;
	T0TCR= 0x01;
	while(T0TC<T0MR0);
	T0TC=0;
   }
}

void clear_screen()
{//	 int i=0;
	 char a=0;
	 char b=0;
 
	for(a=0;a<8;a++)
	{
		IOCLR0|=1<<CS1;
		IOSET0|=1<<CS2;
		lcd_cmd(0x0b8 |a);
		lcd_cmd(0x040);

	 for(b=0;b<128;b++)
	 {
	 	if(b==64)
		{
			IOCLR0|=1<<CS2;
			IOSET0|=1<<CS1;
			lcd_cmd(0x0b8|a);
			lcd_cmd(0x040);
		 }
		 lcd_data(0x000);
	}
}
}
 

int main(void)
{	 
    IODIR0|=0x07fff0;
		
   unsigned char s=0;
 	lcd_initilize();
	while(1)
	{
	IOCLR0|=1<<CS1;
	IOCLR0|=1<<CS2;
/*	lcd_cmd(0x0b8);
	delay(100);
	lcd_cmd(0x040);
	delay(100);
	for(i=0;i<64;i++)
	{
	lcd_data(0x000);
	delay(100);
	} */
	lcd_cmd(0x0b8);
	delay(100);
	lcd_cmd(0x040);
	delay(100);
	for(s=0;s<256;s++)
	{
	lcd_data(0x000);
	delay(100);
	}
	}
   return 0;
}

& my proteus file is this
View attachment New Picture (1).bmp
thanks,
with regards
Abhishek Dixit
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top