All Characters on my LCD dont show, need Help

Thread Starter

Ebuka

Joined Dec 8, 2010
10
Hello ,
Am using an 8051 uController to write to an LCD. Everything about the display is ok with me except that the cursor skips three character spaces before writing. Also only about 14 characters out of a string of 40 is shown. What can I do to get back on track.

thanks.....
 

thatoneguy

Joined Feb 19, 2009
6,359
Have you ever written to an LCD successfully?

Can you step through the code in simulation/debug mode to see what signals are being sent to the LCD?

LCDs are sometimes picky on timing, but if you've gotten past the init, that shouldn't be an issue.

What language are you using? Post the applicable source code.

I'm more of a PIC guy, but can hum a few bars in 8051, esp. if in C.
 

Thread Starter

Ebuka

Joined Dec 8, 2010
10
My codes are below,
Thanks for your support.

Rich (BB code):
#include <REGX52.H>
    #include <string.H>

#define LCD_data P2        // Data will be sent to/recieved from the LCD throught this port P2 
#define LCD_rs P1_0       // Select commd. register  0 = Instruction input        1 = Data input
#define LCD_rw P1_1       //0 = Write to LCD module     1 = Read from LCD module
#define LCD_en P1_2       //  Enable Signal
#define LCD_D7 P1_7       // Busy Flag........
#define LINE1 0x80
#define LINE2 0xC0


void LCD_Power_on(void); 
void LCD_Initialize(void);
void LCD_Busy(unsigned int A);
void Wait_For(unsigned int sec);
void LCD_Get_signal(unsigned char signal);
void LCD_Send_signal(unsigned char *signal,unsigned int max,unsigned char strt_on_linex);
void LCD_Clear_line(unsigned char line);
void LCD_string(char *senpoint, char Line);
void LCD_toggl(void);  // Enable H->L make a high to low pulse

void main (void)
{
int a;
unsigned char  message[] ="Hello every body, hope you all had a wonderful day. Welcome";
              LCD_Power_on();
              LCD_Initialize();
              LCD_Get_signal(LCD_data);
a = strlen(message);
              LCD_Send_signal( message, a,LINE1);
 
}

// Initialization of LCD........................
void LCD_Power_on(void)
{
int a;
for(a=0;a<25000;a++);
}
void LCD_Initialize(void)
{
 LCD_data = 0x38; 
  LCD_Busy(0);          // Enable H->L make a high to low pulse
 Wait_For(200); 
 LCD_data = 0x0F; 
  LCD_Busy(0);          // Enable H->L make a high to low pulse
 Wait_For(200); 
  LCD_data = 0x01;
  LCD_Busy(0);
 Wait_For(200); 
  LCD_data = 0x06;
 LCD_Busy(0);
 Wait_For(200); 
  
}

void Wait_For(unsigned int sec)
{
unsigned char i,j;
        for(i=0;i<sec;i++)
                for(j=0;j<50;j++);
}

void LCD_Busy(unsigned int A)
{
     LCD_rs   = A;        //Selected command register                        
     LCD_rw   = 0;        //We are reading
     LCD_toggl();                         // Read the Busy Flag...
     
     }

 void LCD_toggl(void)
{
//This is our toggle E line function to 
//tell lcd to accept data
    LCD_en=1;     
    LCD_en=0;     
}

void LCD_Get_signal(unsigned char signal)
{
LCD_data = signal;
LCD_Busy(1);
Wait_For(250);
}

void LCD_Send_signal(unsigned char *signal,unsigned int max,unsigned char strt_on_linex)
{
int i;
 Wait_For(200);

LCD_data = strt_on_linex;
LCD_Busy(1);
 Wait_For(200);
for(i=0;i < max;++i){
Wait_For(200);
 LCD_data = signal;
 LCD_Busy(1);
 Wait_For(200);
 Wait_For(200);
Wait_For(200);


if(i == 0x93 || i == 18){
 LCD_data = LINE2;
LCD_Busy(0);
Wait_For(200);
}
else if( i== 34){
LCD_data = 0x01;
LCD_Busy(0);
Wait_For(200);
}


 
}
}

 
Last edited by a moderator:

Thread Starter

Ebuka

Joined Dec 8, 2010
10
In my LCD_send_signal function definition, i tried moving the last 24 characters to the 2nd lime but doesn't work as espected.
 

thatoneguy

Joined Feb 19, 2009
6,359
This part:
Rich (BB code):
void LCD_toggl(void)
{
//This is our toggle E line function to 
//tell lcd to accept data
    LCD_en=1;	 
    LCD_en=0;	 
}
Shouldn't there be a delay between the two port changes? The LCD may not respond that fast.

Also, can you step through and simulate to see if data is being written out to the LCD (or virtual LCD if you have one in the IDE)?
 

Thread Starter

Ebuka

Joined Dec 8, 2010
10
my problem really is moving the last 24 characters in the first line of the LCD to the second line and vice-vasa, this is because i am using a 16x2 LCD and the last 24 characters cant show on the first line.

Pls do help.
Thanxs..........
 

spinnaker

Joined Oct 29, 2009
7,830
If I understand you correctly. You have 24 characters total but 16 characters on each line of the lcd.

You then want to display 16 characters on one line then 8 characters on the 2nd line?


Any reason you have to use assembler? This would be fairly easy to do in C or BASIC.
 

thatoneguy

Joined Feb 19, 2009
6,359
This line in function main():

You may want to test to see if a is longer than 16, if so, break it into line 1 and line 2.
Rich (BB code):
a = strlen(message);
              LCD_Send_signal( message, a,LINE1);
 
Top