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.

4-bit LCD

Status
Not open for further replies.
Hello,

I am trying LCD with two-wire as mentioned by Myke Predko.
I have suceeded till LCD Initialisation but facing problem for second line displaying.
Can you pls tell me how should i go further.

While Initialising i have written-
void LCD_init(void)
{
delay_5ms; //settle time delay
delay_5ms;
delay_5ms;
LCD_nybble(0x03,0); //reset LCD by sending 0x03 low nybble (binary 0011) three times
delay_5ms; //long delay after first one
LCD_nybble(0x03,0); //reset LCD by sending 0x03 low nybble (binary 0011) three times
delay_5ms; //long delay after first one
LCD_nybble(0x03,0); //reset LCD by sending 0x03 low nybble (binary 0011) three times
delay_5ms; //long delay after first one

LCD_nybble(0x02,0); //then send 0x02 low nybble (binary 0010)
delay_1ms();
LCD_cmd(0x28); //set 4-bit mode and 2 lines
delay_4us();
LCD_cmd(0x10); //cursor move & shift left
delay_4us();
LCD_cmd(0x06); //entry mode = increment
delay_4us();
LCD_cmd(0x0f); //display on - cursor blink on
delay_4us();
LCD_cmd(0x01); //clear display
delay_1ms();
// LCD_cmd(0x14); //clear display
// delay_1ms();
}


So, Initializes 2-line & 4-bit mode. but how i get cursor on second line.
I am using "HY-1602F6" (E258603) from SHENZHEN AV-diaplays Co. Ltd

Pls help me for seconh line display

Regards
Supri
 
first off erase your last 4 identical post heh

Code:
	while(1){
		lcd_line1();
		lcd_string("LPC2148 LCD");
		delay_ms(1000);
		lcd_line2();
		lcd_string("It works!");
		lcd_line3();
		lcd_string("Line 3 here.");
		lcd_line4();
		lcd_string("Here is line 4!");
		delay_ms(1000);
	}

The above it Futz code. Just follow the command lcd_lineX()

You can see the cmds needed for jumping to other lines
Code:
void lcd_line1(void)
{
	lcd_cmd(0x80);
}

void lcd_line2(void)
{
	lcd_cmd(0xc0);
}		

void lcd_line3(void)
{
    lcd_cmd(0x94);
}       

void lcd_line4(void)
{
    lcd_cmd(0xd4);
}
I would have just:
Code:
void lcd_line(char line)
{
    switch(line){
        case 1;
            lcd_cmd(0x80);
            break;
        case 2;
            lcd_cmd(0xC0);
            break;
        case 3;
            lcd_cmd(0x94);
            break;
        case 4;
            lcd_cmd(0xd4);
            break;
    }
}

As for INITIALIZING the LCD check out:

https://www.8051projects.net/forum-t4278.html

Second to last post has some code which may help.

Can you post a link to the datasheet for LCD.
 
Last edited:
i did exactly same but second line is not displaying..
where is the problem??

when i put command 0x08 line 1 sarts from 8th cursor position rather than 0'th position.
why line 1 is not started from 0'th position & why second line is not coming.

I had taken lot many trils but didnt found solution...

pls help me out!
 
hi,

Have you successfully written on LCD display?

I am using SHENZHEN AV display's LCD of 16x2;
i am facing problem for displaying on first & second too if use 0x08 & 0xc0 addresses..
Can you help me??
 
ya 0x80 i written for first line but displaying start from 9th place, m not getting whats the problem??
Also with 0xc0 cursor is not coming on second line..??
can you pls look for the solution?
 
It's ABC016002E00-YIY-R-01 Model. If you type "ABC016002E00" on google it will giv u info.
I got one ref program for 16x2 character dot matrix series with SPLC780D from which got instruction set. But it is similar like other 16x2 LCDs

When I write 0x01 then my first line starts. what trials i can take for second line?
 
Do me favor and try going to 0x00 for line 1 and 0x28 for line 2. Tell me if that works. im going to keep reading

EDIT: im not sure if 4-bit mode with 2 lines are possible with this lcd. I onl see it for 8-bit mode

EDIT 2: Can you post your init code for LCD so i can take a look

EDIT 3: if the 0x28 doesnt work try 0x40 for line 2
 
Last edited:
Here is a must for your init. For your lcd to work in 2 line mode and 4-bit this should be done. I dont know how your sending data so this is a generic code i made right now just to show you in closest to plain english what should be done.

Code:
// With:
    RW = 0;
    RS = 0;

// Send function set:
    cmd(0x28);    //4-Bit, 2 lines, 5x8
 
Last edited:
It doesnt work with 0x28 & also with 0x40 for second line. First line works with 0x00 or 0x01.

My LCD init code is-

void LCD_init(void)
{
delay_5ms; //settle time delay
delay_5ms;
delay_5ms;
LCD_nybble(0x03,0); //reset LCD by sending 0x03 low nybble (binary 0011) three times
delay_5ms; //long delay after first one
LCD_nybble(0x03,0); //reset LCD by sending 0x03 low nybble (binary 0011) three times
delay_5ms; //long delay after first one
LCD_nybble(0x03,0); //reset LCD by sending 0x03 low nybble (binary 0011) three times
delay_5ms; //long delay after first one
LCD_nybble(0x02,0); //then send 0x02 low nybble (binary 0010)
delay_1ms();
LCD_cmd(0x28); //set 4-bit mode and 2 lines
delay_4us();
LCD_cmd(0x10); //cursor move & shift left
delay_4us();
LCD_cmd(0x06); //entry mode = increment
delay_4us();
LCD_cmd(0x0f); //display on - cursor blink on
delay_4us();
LCD_cmd(0x01); //clear display
delay_1ms();
}

//*****************************************************************
void LCD_cmd(unsigned char letter)
{
unsigned char temp;
temp=letter;
temp=temp>>4;
LCD_nybble(temp,0);
temp=letter;
temp=temp&0x0f;
LCD_nybble(temp,0);
delay_5ms();
}
//*****************************************************************
void LCD_char(unsigned char letter)
{
unsigned char temp;
temp=letter;
temp=temp>>4;
LCD_nybble(temp,1);
temp=letter;
temp=temp&0x0f;
LCD_nybble(temp,1);
delay_5ms();
delay_5ms();
}
//*****************************************************************
void LCD_nybble(unsigned char nyb,unsigned char rs)
{
int i;
data=0; // clear 74LS174
delay_5ms();
for(i=0;i<6;i++) // repeat for 6 bits
{
clock=1;clock=0; // write 0's to 74LS174
}
data=1; // output the AND value
clock=1;clock=0;
data=rs;

delay_4us();
// output the rs bit value
clock=1;clock=0;
delay_5ms();
for(i=0;i<4;i++) // output the nybble
{
if((nyb & 0x08)!=0)
data=1;

else
data=0;
clock=1;clock=0;
nyb=nyb<<1;
}
e_togg();
delay_4us();
}
//*********************************************************************
void LCD_string(char *point)
{
while(*point !='\0')
{
LCD_char(*point);
point++;
}
}
//**************************************************************************
void e_togg(void)
{
data=1; data=0;
delay_1ms();
}
//*****************************************************************

This is my main code for 2-wire interfacing based on 74LS174 D-FF as shift register.
I think there is no problem of LCD init as it woks well for 1-line display.

At start of second line cursor is not coming. May be other address is there for second line??but i have not seen like this...normally 0x80--> first line & 0xc0--> second line should be ok for all LCD's, m i right??
 
LCD is "HY-1602F6" LCD. Is there any problem with LCD?? but same is happening on other LCs also...i tried on JHD162A also, but same is happening...

Does the application of 2-wire interfacing given by Myke Predko is not suitable for this LCD???

I am not getting solution after lot many trials...pls help
 
which LCD u have used for your display??
shall i use any other???pls specify name so that i can take trials on it..but this is widely used LCD.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top