Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 14th October 2009, 01:15 AM   #1
Default LCD Interfacing with PIC 16f877

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...
Sathiesh Kumar is offline  
Old 14th October 2009, 01:27 AM   #2
Default

Please post your code. Initialize LCD code and initialize micro IO pins....... It is common to not have the pins right.
ronsimpson is online now  
Old 14th October 2009, 02:13 AM   #3
Default

Is the code yours?
Sounds like a hardware problem to me if its only black boxes (or bad software).
__________________
Mike
My website: www.ElectroBird.net
birdman0_o is online now  
Old 14th October 2009, 12:35 PM   #4
Default 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);
}
}
Sathiesh Kumar is offline  
Old 14th October 2009, 12:50 PM   #5
Default

How do you know if the chip is running or not?
__________________
Mike
My website: www.ElectroBird.net
birdman0_o is online now  
Old 14th October 2009, 03:36 PM   #6
Default

I suspect the problem is hardware. You can add an additional program to blink a LED at some other port to make sure that the PIC is executing the code. Also, you can try my code written in mikroC for LCD interface, though I wrote for PIC16F628A.

-Raj
Experiments with PIC16F628A
rajbex is offline  
Old 14th October 2009, 04:08 PM   #7
Default

you can find pre-built library for controlling LCD.....
you can use it if u want to check ur LCD!
fermat7 is offline  
Reply

Tags
interfacing, lcd, pic

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
interfacing PIC 16F877 with gsm mobile project8 Micro Controllers 0 23rd January 2009 11:35 AM
Bunch of questions regarding PIC, PCB fabrication, LCD interfacing and PIC-C xieliwei Electronic Projects Design/Ideas/Reviews 9 3rd May 2008 10:12 AM
Lcd Interfacing With Pic-help Help Help....... samlovesembedded Micro Controllers 4 13th March 2008 02:23 PM
schematic for pic 16f877 and lcd 20 pins jijita Micro Controllers 1 7th September 2004 06:41 PM
clear character in LCD with matriz keypad and pic 16f877 david_mora Micro Controllers 8 19th May 2004 09:33 AM



All times are GMT. The time now is 11:52 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker