We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello there I am trying to display a message on the lcd of this custom designed Microcontroller kit (www.nskelectronics.in/.../8051_project_board.pdf) using P89V51RD2N. I have tried to burn the following program but it just doesn't work.Can someone help me with this ..where am I going wrong.??....
#include <REG51.H> char check = 0x80; sbit EN = P3^4 ; sbit RS = P3^5; //sbit RW = ; //not mentioned on the schematic void delay(); unsigned char array[3]; sfr dat = 0x90; //data lines are connected to LCD from port P1 - as per the circuit void delay(void); void cmd() { RS = 0; //RW = 0; EN = 1; EN = 0; delay(); } void write_lcd() { RS = 1; //RW = 0; EN = 1; EN = 0; delay(); } void init_lcd() { dat = 0x38; cmd(); dat = 0x01; cmd(); dat = 0x0c; cmd(); dat = 0x86; cmd(); dat = 0xdf; write_lcd(); dat = 0x51 ; write_lcd(); } void delay() { int i,j; for(i = 0; i< 75 ; i++) for(j = 0; j < 75 ; j++); } void main() { for(;;) init_lcd(); }
Also I would like to know the purpose of the startup code in a Keil project...Is it obligatory to use the startup code?.
Thanks
1) You haven't told us what you expected to happen.
2) You haven't told us what actually happened.
3) Isn't it a bit boring with a main loop that doesn't do anything but constantly try to initialize the display()?
4) Have you found many web sites recommending for loops to create delays? How do you guarantee that the loop produces the delay you expect it to?
5) You are using a number of magic values - why not give these values a name?
6) Your only comments are //sbit RW = ; //not mentioned on the schematic and //data lines are connected to LCD from port P1 - as per the circuit
That isn't exactly a well-documented program. You can't even say that it is self-documenting, with variable names like "array", "check" and "dat".
That isn't exactly a well-documented program. You can't even say that it is self-documenting, with variable names like "array", "check" and "dat". I know of no one that can say "that it is self-documenting", but know of many that claim so.
Erik
Please note I have posted the latest post since I had not mentioned about the LCD make in the older post
Ok my apologies ....I am a newbie hope you can forgive me for that ...
I am just trying to display a character on the LCD ...Just want to get started by sending a character first and then I would like to get complete understanding about scrolling,displaying various chars on different rows etc...
I have mentioned the link of the project board schematic ..hence the reason for just 2-3 comments.Please take a look at the schematic since I wasn't confident about the RW pin connections for the LCD
Sorry about the programming style I was frustrated about trying this and hence was just trying to get a basic code working on the board
Thanks for the comments will certainly improve.
here is the modified version of the code
//Please note the LCD used in this board is JHD162A #include <REG51.H> sbit EN = P3^4 ; sbit RS = P3^5; //sbit RW = ; //not mentioned on the schematic void delay(); sfr P1_data = 0x90; //data lines are connected to LCD from port P1 - as per the circuit void delay(void); void cmd() { RS = 0; //RW = 0; EN = 1; EN = 0; delay(); } void write_lcd() { RS = 1; //RW = 0; EN = 1; EN = 0; delay(); } void init_lcd() { P1_data = 0x38; cmd(); P1_data = 0x01; cmd(); P1_data = 0x0c; cmd(); P1_data = 0x86; cmd(); P1_data = 0xdf; write_lcd(); P1_data = 0x51 ; write_lcd(); } void delay() { int i,j; for(i = 0; i< 75 ; i++) for(j = 0; j < 75 ; j++); } void main() { for(;;) init_lcd(); }
hence the reason for just 2-3 comments.how about excuse
do you actually think we sit around having nothing better to do than to try to figure out your scribbles?. We are all willing to take a few minutes away from your paid activities, but do not have "figuring out scribbles" time.
additionally the amazing thing is that with good variable names and good comments, you may actually figure it out yourself
from your paid activities should, of course be
from our paid activities
Hello Erik ..sorry if you haven't figured the issue since the comments I provided are of little help .... As per the schematic I have not assigned any value to the variable RW( read / write ) command value variable.The LCD isn't grounded on the PCB too hence I had to mention the link to make sure that you get where exactly the READ/WRITE pin from LCD goes ..its just left out ..and just to mention I am not paid ..still jobless trying my best to learn and move on ...Please let me know where I am going wrong..thanks
its ok a small typo but definitely describes the hectic pressure you would be under ...
its ok a small typo but definitely describes the hectic pressure you would be under I am not under "hectic pressure" but the people that pay me for working would not appreciate if I took time out to figure out your scribbles
This is my last post in this thread, your whines "please check my scribbles" do not affect me.
Ok Erik seems you are disappointed with the way I presented the issue here.I have coded another one this time with proper comments and even this doesn't seem to show anything on the LCD screen...the LCD is glowing but nothing is shown up
#include <reg51.h> #include <stdio.h> #include <intrins.h> //ANSI STYLE PROTOTYPE void lcddata( unsigned char value); void lcdcmd( unsigned char value); void Delay( unsigned int itime ); //SFR names declarations sfr lcd_port = 0x90; sbit RS = P3^5; sbit EN = P3^4; //sbit RW = //not used since schematic doesn't show the pin connecting anywhere void main(void) { unsigned int i,k = 0; //Delay variable unsigned char l[10] = {0x38,0x0E,0x06,0x01,0x41}; //unsigned char l[10] = {0x38,0x01,0x80}; char str[] = "Helloworld"; char str1[] = "welcome"; char *p; //pointer declarations for(i = 0 ;i< 3 ; i++) lcdcmd(l[i]); //sending basic LCD commands to LCD for( p = str; *p ;p++) lcddata(*p); lcdcmd(0xC0); //0xC0 command for displaying on second line for( p = str1; *p ;p++) lcddata(*p); do{ //infinite loop for LCD scrolling lcdcmd(0x18); //0x18 command for LCD scrolling Delay(50); }while(1); } void Delay( unsigned int itime) { int i,j; for( i = 0; i < itime ;i++) for( j = 0; j < 1275; j++); } void lcdcmd( unsigned char value ) { lcd_port = value; RS = 0; //register select = 0 for command mode EN = 1; //latch enable = HIGH _nop_(); EN = 0; //latch enable = LOW Delay(10); return; } void lcddata( unsigned char value ) { lcd_port = value; RS = 1; //register select = 1 for data register EN = 1; //latch enable = HIGH _nop_(); EN = 0; //latch enable = LOW Delay(10); return; }