problem with controlling LCD 16x2 with PIC 16f877

Status
Not open for further replies.

wanbong

Newbie level 5
Joined
Sep 23, 2008
Messages
10
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,350
pic16f877 lcd

hi guys, I'm just an newbie with PIC
I'm trying to control the LCD 16x2 (model SC1602-B) with a PIC 16f877

The simulation of my code on the Proteus 7 can run but when I work with real thing it couldn't print out anything

please help me out, below is my code


Added after 5 hours 48 minutes:

after I ground all the unused pins, there is array of blocks appear in the second line the LCD still can not print out anything
 

io16f877.h

Hi, I think you have problem with pin connection,
for example, I have two tipe of 1602-b LCD,
look on attached pictures,
regards
 
pic lcd 16x2

here is my pins connection
1 GND
2 Vdd
3 GND
4 RA2
5 GND
6 RA3
7->10 GND
11->14 RB0->RB3
15 5V
16 GND
 

connection between pic16f877 with 16x2 lcd

You need an adjustable contrast, put a 10K pot between power, gnd and pin 3 (pin 3 should not be ground but often just slightly above. it can even be negative on some old LCDs) check the datasheet.
 

pic lcd problem

Hi,

1. In lcdinit, change
PORTB = 0x3; // attention
to 0x2 .

2. lcd RAM address is not inited in lcdinit ( By command 0x01 , for CLR display) nor called in the Main function.

3. R/W- pin to be grounded

Regards,
Laktronics
 

lcd 16x2 4bit

thanks for all ur reply finally my LCD can work
the prob is that I connected RS pin wrongly
the point that blueroomelectronics is also correct. If we don't put a potentionmeter for changing the contrast sometimes we can not see the displayed character
 
lcd (16x2 @ 4 bit) c programming

I'm working on something similar, but I'm having trouble getting my LCD (Sanyo DM1622, datasheet at http://www.datasheetcatalog.com/datasheets_pdf/D/M/1/6/DM1622.shtml) to display anything besides 2 rows of 16 squares. Mainly I think it's the initialisation process that's tripping me up.

Pin setup is as follows:
1 GND
2 +5V
3 -5V
4 RA2
5 GND
6 RA3
7->10 GND
11->14 RB0->RB3
15 5V
16 GND

I don't understand some parts of the OP's code.
void IniPort()
{
ADCON1=0x06;
TRISA=0x00;
TRISB=0x00;
PORTA=0x00;
PORTB=0x00;


}

lcd_init(void)
{
LCD_RS = 0; // write control bytes
Why do you need to set LCD_RS = 0 in lcd_init again? When you set PORTA=0x00 in IniPort, isn't LCD_RS already set to 0?

Right now I'm interpreting the lcd_init function as doing the following.

Step 1:
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 1 0 ? ? ? ?
Nothing happens yet, only first 4 bits written

Step 2:
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 1 0 0 0 1 0
The LCD is given the command to do a function set of 4 bits, 1 line, 5*7 dots.

Step 3
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 1 0 ? ? ? ?
Nothing happens yet, only first 4 bits written

Step 4
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 1 0 0 0 1 0
The LCD is given the command to do a function set of 4 bits, 1 line, 5*7 dots.



From the information I get from this page http://www.8051projects.net/lcd-interfacing/lcd-4-bit-programming.php
the initialisation for 4-bit mode for a similar LCD is as follows How do you have
lcd_port = 0xFF;
when you're only using 4 bits?
 

Re: lcd (16x2 @ 4 bit) c programming

I am also facing the same problem
 

Re: lcd (16x2 @ 4 bit) c programming

I am also facing the same problem

Why are you digging out a year old problem and saying "same problem".

Instead you can start a new thread explaining your problem.
 

Can someone tell me what was wrong in wanbong's coding and what was changed? I would like a full correct coding of it if possible. Thanks.
 

CSS C compiler has the built in function of controlling LCD.
16x2 LCD interfacing with PIC-16f877a is available.
To get this and to get complete help regarding this feel free to contact on asharwahid@yahoo.com
 

Attachments

  • lcd.jpg
    88.6 KB · Views: 123

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…