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??