LCD interfacing with pic24FJ64GA110


#1

Hello sir,
I am trying to interface LCD with PIC24FJ54GA110 controller but, nothing is displayed on LCD in the Proteus simulation.

Here is my code:-
int main(void)
{
TRISD = 0;
RS = 0;
EN = 0;
lcd_port = 0;

lcd_command (0x80);
lcd_string("hello");
lcd_command(0xC0);
while(1);

}

library:-

void lcd_init()
{
TRISD = 0; // SET THE PORTD AS THE OUTPUT
__delay_ms(200);
//lcd_command(0x02);// send 4-bit to LCD
lcd_command(0x28); //4-bit 2 line
lcd_command(0x0E);// DISPLAY ON CURSOR ON
lcd_command(0x01);// CLEAR THE LCD
lcd_command(0x06);//INCREMENT CURSOR BY
}

// lcd_command function//
void lcd_command(unsigned char cmd)
{
lcd_port = (lcd_port & 0x0F) | (cmd & 0xF0); //SET THE PORT IN THE MAIN CODE . SENDING THE UPPER NIBBLE
RS = 0;// ENABLE THE COMMAND MODE
EN = 1; // ENABLE THE COMMAND
__delay_ms(200);
EN = 0;
__delay_ms(500);

lcd_port = (lcd_port & 0x0F) | (cmd << 4); //sending the lower nibble

EN = 1;
__delay_ms(200);
EN = 0;
__delay_ms(400);

}

// lcd_character function to send the data//
void lcd_character(unsigned char data)
{
lcd_port = (lcd_port & 0x0F) | (data & 0xF0); //sending the upeer four nibble
RS = 1;
EN = 1;
__delay_ms(200);
EN = 0;
__delay_ms(500);
lcd_port = (lcd_port & 0x0F) | (data << 4);//sending lower four nibble data
EN = 1;
__delay_ms(200);
EN = 0;
__delay_ms(400);
}

// lcd string to show the data on lcd
void lcd_string( char *str)
{
int i;
for (i=0;str[i];i++)
{
lcd_character (str[i]);
}
}

void lcd_string_xy(char row,char pos, char *str)
{
if (row == 0 && pos<16)
{
lcd_command((pos & 0x0F)|0x80);
}
else if(row == 1 && pos<16)
{
lcd_command((pos & 0x0F)|0xC0);
}
lcd_string(str);
}