Keil Logo Arm Logo

Discussion Forum

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

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
jd s
Posted
26-Apr-2012 15:18 GMT
Toolset
C51
New! 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);
} }

Read-Only
Author
Erik Malund
Posted
26-Apr-2012 22:29 GMT
Toolset
C51
New! RE: unable to find mistake in program....if u could help?

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

Read-Only
Author
Neil Kurzman
Posted
28-Apr-2012 02:45 GMT
Toolset
C51
New! RE: unable to find mistake in program....if u could help?

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.

Read-Only
Author
Phil Zealand
Posted
30-Apr-2012 11:35 GMT
Toolset
C51
New! RE: unable to find mistake in program....if u could help?

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.

Read-Only
Author
jd s
Posted
30-Apr-2012 12:42 GMT
Toolset
C51
New! RE: unable to find mistake in program....if u could help?

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

Read-Only
Author
erik malund
Posted
30-Apr-2012 14:33 GMT
Toolset
C51
New! when specifically addressing micro (u) use e-mail

can u tell me

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.