This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

unable to find mistake in program....if u could help?

Below is the program for moving message on lcd.....ws not working on chip....if u can help me any modifications..it is for philips P89v51rd2fn
lcd is jhd162a

#include<reg51.h>
sfr lcd_data_pin=0x90; // port 1
sbit rs=P3^0; // Register select pin
sbit rw=P3^1; // Read write pin
sbit en=P3^2; // Enable pin

void delay(unsigned int msec) //delay function
{ int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}

void lcd_cmd(unsigned char comm) // function to send command to LCD
{ lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(25);
en=0;
} void lcd_data(unsigned char disp) // function to send data on LCD
{ lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(25);
en=0;
}

void lcd_puts(unsigned char *s) // function to send string to LCD
{ while(*s!='\0')
{ lcd_data(*s);
s++;
} }

void lcd_ini() //Function to initialize the LCD
{ lcd_cmd(0x38);
lcd_cmd(0x06);
lcd_cmd(0x80);
lcd_cmd(0x01);
lcd_cmd(0x0C);
} void main()
{ lcd_ini();
lcd_cmd(0x81);
lcd_puts("HELLO");
delay(25);
while(1)
{ lcd_cmd(0x1C); //Shift the entire display to right delay(50);
} }

  • if u could help
    when you save characters by using 'u' instead of 'you' is save one typing 'no' instead of 'yes'

    BTW evidently you are unable to read the instructions over the message entry field, did you not notice that the preview was incomprehensible.

    Erik

  • You have the Hardware and can not find the error. You expect other to just read it an find the Issue.
    What does "ws not working on chip" Mean?
    No Display? Check the contrast
    Boxes in row 1? The Init timing is wrong.

  • Without knowing the LCD controller comands, one could possibly think that maybe it is working... just too fast for you to see (or the slow LCD segments to have time to change state)

    so looking at the last few lines:
    - display hello,
    - call delay routine for 25ms,
    - then the final loop shifts the display to right as fast as possible - read as very fast because the delay(50) is in the comments and not in code.

    so to analyse: display hello, then after 25mS, shift it very rapidly off the screen. even if the LCD could display the 'HELLO' in 25mS (LCD's are pretty slow), your' eyes are not that fast.

    As a seperate subject, it is bad form to create delays using software loops - use a hardware timer. Software loop timers will one day sooner or later come back to bite you in so many ways!

    - Phil.

  • owk..but is rest program right? i have a doubt regarding the header file..can u tell me header file for phiilips p89v51rd2fn?