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.

Writing on single pixel of Graphical LCD using 8051

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
I am using AT89C51 Micro-Controller to interface it with my Graphical LCD,

Writing works fine, means i had displayed the Images on Graphical LCD, but my requirement is to just high and low a single pixel on graphical lcd...

But i don't know, why it doesn't works. (I am using KS0108 Based Graphical LCD)

Code:
//Connection Diagram
sbit GLCD_RS = P1^2;
sbit GLCD_RW = P1^3;
sbit GLCD_EN = P1^4;
sbit GLCD_CS1 = P1^0;
sbit GLCD_CS2 = P1^1;
sbit GLCD_RST = P1^5; 

sfr GLCD_DATA = 0xA0;

This is my connection diagram
Code:
//These are two macros definition for setting and clearing a single bit
#define bit_set(var,bitno) ((var) |= 1<<(bitno))
#define bit_clear(var,bitno) ((var) &= ~(1<<(bitno)))

void delay_small()
{
	unsigned char counter;
	for(counter=0;counter<8;counter++);
}
void GLCD_PULSE()
{
	GLCD_EN = 1;
	delay_small();
	GLCD_EN = 0;
}

void CHIP_LEFT()
{
	GLCD_CS1 = 1;
	GLCD_CS2 = 0;
}
void CHIP_RIGHT()
{
	GLCD_CS1 = 0;
	GLCD_CS2 = 1;
}

//Write Function
void glcd0108_write(unsigned char c)
{
	GLCD_RW = 0;	//Clear for Writing the Data
	GLCD_DATA = c;
	GLCD_PULSE();
}


unsigned char glcd0108_read(bit side)
{
	unsigned char lcd_data;
	//Set GLCD Data Pins as Input Pin
	GLCD_DATA = 0xFF;

	GLCD_RW = 1;	//Set the RW pin for Reading Purpose

	GLCD_RS = 1;	//Read Datasheet for Reading Purpose RS and RW pin must be High

	CHIP_LEFT();
	//Left Side Selected By Default

	if(side == 1)
	{
		//Select Right Side
		CHIP_RIGHT();	//Right Side Selected
	}
		
	delay_small();	//Give Some Delay
	GLCD_EN = 1;	//GLCD_EN --> High
	delay_small();
	lcd_data = GLCD_DATA;	//Get the data from the GLCD Data Pins
	lcd_data = GLCD_DATA;
	GLCD_EN = 0;	//GLCD_EN --> Low

	//Reset The Chip Select Lines
	GLCD_CS1 = 1;
	GLCD_CS2 = 1;
	return lcd_data;
}

void glcd0108_pixel(unsigned char x,unsigned char y,bit color)
{
	unsigned char lcd_data;
	bit side;
	//Set Side to Chip Left First
	CHIP_LEFT();
	side = 0;	//Initially Set Side = 0
	//if the value of x exceed the 63 then select Chip Right

	if(x > 63)
	{
		x = x - 64;
		CHIP_RIGHT();
		side = 1;
		//Right Chip Selected
	}

	GLCD_RS = 0;	//Setting LCD Controller for Instruction
	//Clear the MSB part of the Instruction Code
	bit_clear(x,7);
	//Set bit 6 also the part of Instruction Code
	bit_set(x,6);
	glcd0108_write(x);	//Set the Horizontal Address
	glcd0108_write( (y/8 & 0xBF) | 0xB8);	//Set the Vertical Page Address

	GLCD_RS = 1;	//Setting LCD Controller for Data

	lcd_data = glcd0108_read(side);	//Based on the above value of side read the Graphical LCD
	//Need two reads to get data
	lcd_data = glcd0108_read(side);
	if(color == 1)
		bit_set(lcd_data, (y%8));	//Turn on the Pixel
	else
		bit_clear(lcd_data, (y%8));	//Turn off the Pixel

	GLCD_RS = 0;	//Set for Instruction
	CHIP_LEFT();
	if(side == 1)
	{
		CHIP_RIGHT();
	}
	glcd0108_write(x);
	GLCD_RS = 1;	//Set for data
	glcd0108_write(lcd_data);
}


The function glcd0108_pixel(1,1,1); will dark the pixel on 1,1 the last one specify the dark and if replaced by zero will produce white pixel..

pls have a look at my code...
and tell me what is the problem..


i am also writing my main part
Code:
void main()
{
int i;
	P3 = 0x00;
	P0 = 0x00;
	P1 = 0x00;
	P2 = 0x00;
	glcd0108_init();	
	delay_ms(1);
        glcd0108_clear();  //Clears the Display
        P3 = glcd0108_read(0);
	glcd0108_pixel(1,1,1);
	while(1);
}
 

I have taken half of code from your site, and changed that for 8051 and it works fine..
But i want to display only a single point (.) at different points on LCD.
For that i have to read the status at that.

And a buffer is not required for this, it can be done without the buffers, Bu i am not able to do...

any suggestion...
Pls
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top