Hi!
I have a problem with interfacing PIC with LCD. I use Proteus simulation. The initialization is OK - in simulation the cursor start blinking, But I can not send the characters to display.



Code:
#include 

#define E RB4
#define RS RB5
#define D4 RB0
#define D5 RB1
#define D6 RB2
#define D7 RB3

void waitms(int ms)
{
  volatile int i,j;
  for (i=0;i>4;
  PORTB=pv; // high bits
  E_pulse();
 waitms(5);
  pv = cmd&0x0f;
  PORTB=pv; // low bits
  E_pulse();
  waitms(10);
}
void LCD_chr(char data[])
{
  int i;
  int pv;
  int ch;
  E=0;
  RS=1; // LCD data mode
  for(i = 0; data[i] != 0; i++)
  {
    ch=data[i];
    pv=ch>>4;
    PORTB=pv; // high bits
    E_pulse();
    waitms(5);
    pv=ch&0x0f;
    PORTB=pv; // low bits
    E_pulse();
  }
waitms(10);
}
void LCD_locate(int row, int column)
{
 RS=0;
  if(row == 1)
  {
    LCD_cmd(0x80 | (column - 1)&0x0f);
  }
  else
  {
    LCD_cmd(0xc0 | (column - 1)&0x0f);
  }  
  
  waitms(5);  
}
void LCD_init(void)
{
  TRISB=0;
  waitms(40);
  RS=0;
  PORTB=0x3;
  E_pulse();
  waitms(6);
  PORTB=0x3;
  E_pulse(); // init!
  waitms(6);
  PORTB=0x3;
  E_pulse(); // init!
  waitms(6);
  PORTB=0x2;
  E_pulse();
  LCD_cmd(0x28); 
  LCD_cmd(0x08); 
  LCD_cmd(0x01); 
  waitms(5);
  LCD_cmd(0x06);
  LCD_cmd(0x0f);
  waitms(1);
}

void main(){
LCD_init();
waitms(10);
LCD_chr("test");

while(1){
}
}
Click image for larger version. 

Name:	LCD.JPG 
Views:	14 
Size:	206.6 KB 
ID:	86660

Thanks for your help!