
while(1)	 
	{	P1 = 0;					// prog has ended turn on led
		MSDelay(1000);

		for(y=0;y<8;y++)		   	//just wanted to read the LCD
		//	setpage(y,1);   //they dont seem to work :(
		//	setcolumn(x,1);
		  	for(x=0;x<64;x++)
			{
				P0 = lcdread(y,x,1);   //P0 just shows random data, dont kno even if it's random!
				MSDelay(1000);		//delay between successive reads
			}						//to see leds blinking acc to data on disp
		//	setpage(y,2);
		//	setcolumn(x,2);
			for(x=0;x<64;x++)
			{
				P0 = lcdread(y,x,2);
				MSDelay(1000);
			}

		}
	//P0 = lcdread(3,8,1);
	}
unsigned char lcdread(unsigned char page, unsigned char column, unsigned char chipselect)
{
	setpage(page, chipselect);
	setcolumn(column, chipselect);
	
	ldata=0xFF;		//make I/P port	to read data
//	en=0;	
	rw=1;				// now reading from the LCD			
	en=0;
	rs=1;				//data
	if(chipselect==1)  	// if in Left half of LCD
	{
		cs1=1;
		cs2=0;
	}
	else			 //nahi to right half
	{
		cs1=0;
		cs2=1;
	}
	en=1;	   //now data wud have come to port
	return(ldata);
}
void setpage(unsigned char y, unsigned char chipselect)
{
	lcdcmd(0xB8+y,chipselect);	
}
void setcolumn(unsigned char x, unsigned char chipselect)
{
	lcdcmd(0x40+x,chipselect);
}
void lcdcmd(unsigned char cmd, unsigned char chipselect)
{	
	rw=0;			
	if(chipselect==1)  	//if in Left half of LCD
	{
		cs1=1;
		cs2=0;
	}
	else	 //nahi to right half
	{
		cs1=0;
		cs2=1;
	}

	rs=0;				//command
	ldata = cmd;
	en=1;
	//for(a=0;a<10;a++);	//lill delay
	en=0;	

}


