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.

Help in programming Graphic LCD with 18F4520

Status
Not open for further replies.

hemnath

Advanced Member level 3
Advanced Member level 3
Joined
Jun 24, 2012
Messages
702
Helped
61
Reputation
120
Reaction score
57
Trophy points
1,308
Location
Chennai
Visit site
Activity points
6,589
Hi Friends,
I'm interfacing KS0108 GLCD with PIC18F4520 controller. Compiler: CCS C. I have read the datasheet of KS0108 GLCD. But still i feel difficult in writing the code. I want to display "Hellow" in GLCD.

As a newbie in Graphic LCD, i tried CCS example and it was working good.

All i want to do is, making my font size as flexible. In CCS C compiler, there are only 2 font sizes which are 5x7 and 10x14. There are some instances where i will display some big size characters than 10x14. Also in CCS, there are inbuilt commands to use the X and Y addresses.

Now I'm writing the code as mentioned in datasheet. I want to display a character 'H' in the display. Please check initialization is correct? how to define hex values for character 'H'? Please help.

HTML:
unsigned char data[] = {127,127,8,8,127,127,0,0};  // H, 8x8

void GRAPHIC_LCD_INIT()
{
	output_high(RESET);   // RST connected to PIN_C0
	output_high(CS1);      // CS1 connected to PIN_B0
	output_high(CS2);     //  CS2 connected to PIN_B1
	
	glcd_cmd(0x3F);		// Display ON

	 glcd_cmd(0xB8);		// Page selection - Page 1
	 glcd_cmd(0x40);		// Column selection
			
}

void glcd_cmd(unsigned char c)
{
   output_d(c);
   output_low(RS);
   output_low(RW);
   output_high(EN);
   delay_ms(15);
   output_low(EN);
}

void glcd_data(unsigned char z)
{
   output_d(z);
   output_high(RS);
   output_high(RW);
   output_high(EN);
   delay_ms(15);
   output_low(EN);
}

void main()
{
	GRAPHIC_LCD_INIT();

	while(1)
	{	
		glcd_cmd(0xC0);   // display start line
		glcd_data(data);
	}
}

Thanks in advance.
 

Hi, Thanks for your reply.
I've already checked the tutorials provided by MicroElektronika.
They use only inbuilt commands for initialization, data send,etc...

Can you check the above program if possible. Whats wrong in that program?

Thanks.
 

could you try to change glcd_data function:

Code:
void glcd_data(unsigned char z)
{
   output_high(RS);
   output_low(RW);
   output_d(z);
   output_high(EN);
   delay_ms(15);
   output_low(EN);
}
 
Last edited by a moderator:

Still the problem remains the same.
Nothing is displayed on the GLCD. Need some solution.

Thanks,
 

Could you try this code?
If can't run, you change value of data array and check your connection.
Code:
[syntax=c]
unsigned char data[] = {127,127,8,8,127,127,0,0};  // H, 8x8

void GRAPHIC_LCD_INIT()
{
	output_high(CS1);      // CS1 connected to PIN_B0
	output_high(CS2);     //  CS2 connected to PIN_B1
	output_high(RESET);   // RST connected to PIN_C0
	
	glcd_cmd(0x3F);		// Display ON

        glcd_cmd(0xB8);		// Page selection - Page 1
	glcd_cmd(0x40);		// Column selection
			
}

void glcd_cmd(unsigned char c)
{
   output_d(c);
   output_low(RS);
   output_low(RW);
   output_high(EN);
   delay_ms(15);
   output_low(EN);
}

void glcd_data(unsigned char z)
{
   output_d(z);
   output_high(RS);
   output_low(RW);
   output_high(EN);
   delay_ms(15);
   output_low(EN);
}

void main()
{
        int i;
	GRAPHIC_LCD_INIT();     
        glcd_cmd(0xC0);   // display start line
	while(1)
	{	
               for (i = 0; i < 8; i++)
	     	     glcd_data(data[i]);
	}
}[/syntax]
 

Yes i tried the above program. And I'm simulating in Proteus. Still no character on the display.

Is there anything else missing?
I have checked the connections again and it is correct.

Thanks,
 

Could you try changed the main function as below?
Code:
void main()
{
   int i;
   GRAPHIC_LCD_INIT();     
   output_low(CS1);      // CS1 connected to PIN_B0
   output_low(CS2);     //  CS2 connected to PIN_B1
   glcd_cmd(0xC1);   // display start line
    while(1)
    {      
      for (i = 0; i < 8; i++)
      {
         /*printf(glcd_data,"%d",data[i]);*/
         glcd_data(data[i]);
      }
    }
}
 
wow its working. Thanks a lot.
Why CS1 and CS2 are pulled low??

Also in display, it shows
HHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHH
HHHHHHHHHHHHHHHH

Why it prints on first 4 lines?? I want to print H in first position only.

Thanks,
 

CS1 and CS2 to choose paper of LCD to display. (I think that is reason, it print on first 4 lines).
you can call glcd_cmd(0xC0); in loop ('while(1)') to go to 1st position to display.
 

yes i have changed the program to,

HTML:
while(1)
{
glcd_cmd(0xC0);
 for (i = 0; i < 8; i++)
 {
   glcd_data(data[i]);
 }
}

But the display remains the same.
 

I'm wrong. You need add function to control cursor as goto x,y position OR display 'H' character only one time.
 

Yes, the problem is solved. When i changed the line,
HTML:
glcd_cmd(0xC0);
to
HTML:
	glcd_cmd(0x40);

Thanks you so much.

Now i have another task, Is it possible to display a character with 15 x 15??? I'm very confused in writing the code.
For every page, it is only 8 bits. Right? If i want to display bigger characters how can i select the page?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top