How about this:
Before:
//*******************************************************
void lcdCommand( unsigned char cmnd )
{
LCD_DPRT = cmnd;
LCD_CPRT &= ~ (1<<LCD_RS); // LCD_RS/LCD_RW pins of PortB are cleared...
LCD_CPRT &= ~ (1<<LCD_RW); // ...as required to send commands to LCD.
LCD_CPRT |= (1<<LCD_EN); // LCD_EN pin of PortB is set (pulsed)for internal latching to send a command.
delay_us(.02); // delay 20 ns for LCD module to run a command.
LCD_CPRT &= ~ (1<<LCD_EN); // LCD_EN pin of PortB is cleared after sending a command.
delay_us(.26); // delay 260ns between commands sent.
}
//*******************************************************
After:
//*******************************************************
void lcdCommand( unsigned char cmnd )
{
LCD_DPRT = cmnd; // set up data lines
LCD_CPRT &= ~ (1<<LCD_RS); // RS low, select 'instruction' register
LCD_CPRT &= ~ (1<<LCD_RW); // RW low, 'write' data to LCD
// pulse the Enable pin - data is transferred on the falling edge
LCD_CPRT |= (1<<LCD_EN); // Enable high
delay_us(.02); // Enable must be high for at least 230nS
LCD_CPRT &= ~ (1<<LCD_EN); // Enable low
delay_us(.26); // Enable must be low for at least 230nS
}
//*******************************************************
Now compare this to the timing diagram in the data sheet (NOT in the textbook) and find out what is missing and/or wrong.
I haven't looked at the rest of your code yet.
Don