Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

User defined graphics in 16x2 LCD (HDD44780)

Status
Not open for further replies.

Vizier87

Active Member
Hi guys,
As I started using the LCD further, I'm stuck at the instructions I read from the manual. Basically it says:

1. Display on/off cursor commands
2. Clear display
3. Set display address
4. Display data 0x00 to 0x07
5. Set CGRAM address
6. Enter data to build the character

Basically I'm trying to display the character "lambda" λ.

Here's my code: (My portd pins are reverse to the data pins, sorry :) )
C:
     rs=0;
     portd=0x01; //display address 0x00
     enter ();

     //Entering "garbage bits" for display//

     rs=1;
     Delay_us(100);
     enter();

     portd=0x00;
     enter ();
     portd=0x80;
     enter ();
     portd=0x40;
     enter ();
     portd=0xc0;
     enter ();
     portd=0x20;
     enter ();
     portd=0xa0;
     enter ();
     portd=0x60;
     enter ();
     portd=0xe0;
     enter ();

     ///////////////////////
     rs=0;
     portd=0x40;     // Set CGRAM Address: 0b01AAAAAA
     enter ();

     // Start defining character /////
     rs=1;
     portd=0x10;     ///
     enter ();         //
     portd=0x10;       //
     enter ();         //
     portd=0x20;       //
     enter ();         //
     portd=0x20;       //
     enter ();         //
     portd=0x60;       ///
     enter ();           ///  LAMBDA
     portd=0x50;       ///
     enter ();         //
     portd=0x50;       //
     enter ();         //
     portd=0x88;       //
     enter ();      ///
     //////////////////////////////////

I think I'm nearly getting there (displays some rubbish). Anyone can advise on the code?
Also, how do I access the same character again? Is it by entering the same data as defined by the CGRAM?


Thanks everyone.
Vizier87
 
This is my bar graph... I define the characters first

Code:
rom char lcddef[]={	0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
			0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,
			0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x00,
			0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x00,
			0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x00,
			0x00,0x00,0x00,0x14,0x14,0x15,0x18,0x00,
			0x1e,0x10,0x11,0x1c,0x10,0x11,0x10,0x00};

And insert them in one loop

Code:
LCDcmd(0x48);
	for(x=0;x<56;x++)
		{
		while(LCDbusy());
		LCDdata(lcddef[x]);
		}

The characters are then 0 - 7 AND 8 - 15 ( on most devices )

LCDdata(6); will print the last character ( I only use 7 )
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top