pic16f877a

Thread Starter

mahmood102

Joined Jan 18, 2013
23
hi
i connect the lcd 1602a with pic16f877a and i write the code to display hello world but i did not see any thing on the lcd

can any one help me please
 

Thread Starter

mahmood102

Joined Jan 18, 2013
23
RS at RD0
EN at RD1
LCD_D4 at RD4
LCD_D5 at RD5
LCD_D6 at RD6
LCD_D7 at RD7
pin1 of lcd at GND
pin2 of lcd at +5v
pin3 of lcd to variable resistor 10k
 

t06afre

Joined May 11, 2009
5,934
RS at RD0
EN at RD1
LCD_D4 at RD4
LCD_D5 at RD5
LCD_D6 at RD6
LCD_D7 at RD7
pin1 of lcd at GND
pin2 of lcd at +5v
pin3 of lcd to variable resistor 10k
That is not a schematic. You need to draw the schematic and post it. Also the code important. And we need you to post all of it. Not just some part of it.
 

tshuck

Joined Oct 18, 2012
3,534
hmmm... that doesn't look like a schematic...

So you are using a character LCD display and is probably a HD44780 type, no?

Looks also like you are trying to run it in 4-bit mode, despite the fact that you have plenty of I/O, is there a reason for that?

Anyway, post your code, your schematic, and what you've done to debug the problem and we can move along.:)
 

Thread Starter

mahmood102

Joined Jan 18, 2013
23
sbit LCD_RS at RD0_bit;
sbit LCD_EN at RD1_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connection definition
//3- Define Messages
char message1[] = "Welcome to";
char message2[] = "ENG.F.ABDELAZIZ";
//4- Main function
void main()
{
//4-a- set up ports
TRISD = 0; // PORTD All Outputs
PORTD=0; // clear

//4-b- set up LCD
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // CLEAR display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
// 4-c- Infinite Loop
while(1) {

//4-c-1-send strings
Lcd_Out(1,4,message1); // Write message1 in 1st row,begin from Column 4
Lcd_Out(2,1,message2); // Write message2 in 2nd row,begin from Column 1
//4-c-2--delay 1 sec.
Delay_ms(1000); // Wait for 1 sec
//4-c-3--clear LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
//4-c-4-delay 1 sec.
Delay_ms(1000); // Wait for 1 sec
} // Infinite Loop
}
 

Attachments

tshuck

Joined Oct 18, 2012
3,534
Yes, although you should use the code tags when pasting code... it's in the toolbar as the '#' symbol...

I see one REALLY big problem... you have no oscillator. the 16F877A doesn't have an internal oscillator.....
 

Thread Starter

mahmood102

Joined Jan 18, 2013
23
sorry this drawing just the connection for the lcd .
but for the pic i used 4mhz oscillator.
i test the code for the led and its work but know i tray to make the connection with lcd to display the message but its not work
 

tshuck

Joined Oct 18, 2012
3,534
Are you using a library for your LCD_X routines? If so, which? If not, post these functions..


Basically, we need to see what's going on here, post your full code...
 

Thread Starter

mahmood102

Joined Jan 18, 2013
23
ok can you tell what can i do
or why the lcd not working
if you can please tell how can i connect the lcd to this pic and display a message on it
 

t06afre

Joined May 11, 2009
5,934
Ok so this setup work in Proteus. But not in the real world is that correct? Or do you struggle just to make it work in Proteus
 

tshuck

Joined Oct 18, 2012
3,534
this is the full code i am use it by mikroC
Then where are the Lcd routines defined?

ok can you tell what can i do
or why the lcd not working
if you can please tell how can i connect the lcd to this pic and display a message on it
Without knowing what you are using, I can only guess...

The library you are using may assume an 8-bit interface, which will cause your 4-bit interface to not work.

Your Lcd_Init() may not be taking into account the 4MHz clock you have and the timings may be off...
 

Thread Starter

mahmood102

Joined Jan 18, 2013
23
ok
forget every thing i am do it.
can you tell what i have to do to connect the lcd with pic16f877a and write a simple code for test it.
 
Top