Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD Interfacing with PIC 16f877

Status
Not open for further replies.

Sathiesh Kumar

New Member
Hi,
I am new to microcontroller programming...I would like to interface a LCD with Pic 16f877.. but i think that there is a problem in initializing the LCD...I could not able to initialize the LCD...LCD just displays black boxes...
Compiler:MickroC
Programmmer:pIC start Plus
Programming :C

I can initialize an LCD when i connect it with 89C51...But i cant do the same thing with Pic microcontroller.. What might be the problem?

Whether its the problem due to compiler or code or Programmer..

Can any one help me...

Please...
 
Please post your code. Initialize LCD code and initialize micro IO pins....... It is common to not have the pins right.
 
Code for LCD Interfacing with 16f877

Thanks for your reply... I have attached the code which i tested in MicroC compiler... But it shows the black boxes... Help me

Program 1:

#define ldata PORTD
#define rs PORTB.F0
#define rw PORTB.F1
#define en PORTB.F2
void lcdcmd(unsigned char );
void lcddata(unsigned char );
void msdelay(unsigned char);
void main(void)
{
TRISD=0;
TRISB=0;
en=0;
msdelay(25);
lcdcmd(0x38);
msdelay(25);
lcdcmd(0x0E);
msdelay(15);
lcdcmd(0x01);
msdelay(15);
lcdcmd(0x06);
msdelay(15);
lcdcmd(0x86);
msdelay(15);
lcddata('A');
msdelay(15);
lcddata('D');
msdelay(15);
lcddata('E');
}
void lcdcmd(unsigned char value)
{
ldata=value;
rs=0;
rw=0;
en=1;
msdelay(1);
en=0;
}
void lcddata(unsigned char value)
{
ldata=value;
rs=1;
rw=0;
en=1;
msdelay(1);
en=0;
}
void msdelay(unsigned char itime)
{
unsigned char i,j;
for(i=0;i<itime;i++)
for(j=0;j<135;j++);
}


Program 2:This program i downloaded it from net.. This program too gives the same output...

char *text= "EQBYTE for All";
signed char data[12];
int i=0;
void main (){
TRISB = 0; // PORTB is output
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
while (1) {
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
for (i=1;i<11;i++)
{
Delay_ms(200);
IntToStr(i,data); //Numeric to string transform (i to data)
Lcd_out(1,1,"Value="); // Print fixed text to LCD (e.g "Value")
Lcd_out(1,8,data); // Print variable text to LCD, 1st row, 8th column (e.g data)
Delay_ms(200);
}
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Out(2, 1, text); // Print text to LCD, 2nd row, 1st column
Delay_ms(1200);
}
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top