Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] LCD with PIC16F877A problem

Status
Not open for further replies.

kobre98

Full Member level 2
Joined
Sep 18, 2011
Messages
145
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Gaza, Palestine
Activity points
2,523
Hey guys,
I have a project in which I need to interface LCD with pic16f877a
When I use 4MHz crystal it displays and everything works fine

But when I use any other crystal 8MHz or 20Mhz

It only displays black rectangles, I really need to switch it to 20Mhz and keep the LCD working

Don't know what the problem is.
 

anboli

Full Member level 2
Joined
Mar 9, 2012
Messages
143
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
2,507
Post the configuration details here...
 

Vbase

Full Member level 6
Joined
Apr 7, 2015
Messages
367
Helped
74
Reputation
148
Reaction score
72
Trophy points
28
Activity points
1,997
The LCD requires several delays for initialization and for moving to new lines. When you increase the osc to 20MHz the delays get shorter and the LCD can't work properly.
You have to find all the delays involving LCD and correct them. You also have to make sure that the clock isn't shorter than 1uS.
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,354
Helped
4,724
Reputation
9,463
Reaction score
4,492
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
122,499
It appears you are using software generated delays in your program. As the clock speed is increased, the delays become shorter and are probably no longer meeting the minimum required by the LCD module. Look in the source code and see if the clock frequency is defined (usually near the top of the program), if it is, change it to match the new frequency and recompile. If it isn't specified in the program, you may have to manually scale all the delays to make them longer.

Brian.
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Use my LCD library. You only have to make a Delay_ms() function which gives proper delay. Mention which Compiler you are using. Zip and post your Complete project files.
 

Attachments


kobre98

Full Member level 2
Joined
Sep 18, 2011
Messages
145
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Gaza, Palestine
Activity points
2,523
Thanks a lot for your help
I use mikroC compiler v 8
I added delay after Lcd_initialize()
and in several places of the code but it didn't seem to work, same black boxes, how can I know where exactly should I place the delay and what is the amount of the delay.

How to use this Lib with mikroC ?!

Thanks again
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
If you use mikroC then you don't need to use my library. I also use mikroC. It has LCD library. I just made a library which is similar to mikroC LCD library. Please zip and post the complete mikroC project files. I will test your project for different clock frequencies in hardware. mikroC Delay functions generate proper delays for all clock frequencies.
 

kobre98

Full Member level 2
Joined
Sep 18, 2011
Messages
145
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Gaza, Palestine
Activity points
2,523
I will try it but could you please tell me what changes have you made to this code ?!
so that I can make it to any code where I want to use LCD and avoid the black boxes issue
and does the type of LCD make any difference in the black boxes issue?!
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
I have just used


Code C - [expand]
1
TRISB = 0x00



You should use HD44780 or compatible LCDs.
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,181
Helped
1,140
Reputation
2,299
Reaction score
1,116
Trophy points
1,403
Location
Brazil
Activity points
53,319
I have just used

Code C - [expand]
1
TRISB = 0x00

Seems like this have no relation with original problem.

When I use 4MHz crystal it displays and everything works fine
But when I use any other crystal 8MHz or 20Mhz
It only displays black rectangles
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Maybe an issue with Ceramic Capacitor values used for Oscillator Circuit.
 

Vbase

Full Member level 6
Joined
Apr 7, 2015
Messages
367
Helped
74
Reputation
148
Reaction score
72
Trophy points
28
Activity points
1,997
Maybe an issue with Ceramic Capacitor values used for Oscillator Circuit.
If the caps were the problem then he would have got blank display.
Why did you say it's a fixed code if you can't tell the difference?
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
I said fixed because I use mikroC all the time and I gave the code which I use. I also tested the code with different crystals on EasyPIC v7 and it worked fine without problems. Maybe the problem is in his hardware.
 

kobre98

Full Member level 2
Joined
Sep 18, 2011
Messages
145
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Gaza, Palestine
Activity points
2,523
It didn't work !
I really don't know what is the problem
this is frustrating
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Don't waste time debugging code. Code is fine. I have tested for 4 MHz, 8 MHz and 20 MHz in EasyPIC v7 and it works fine. Try to adjust contrast of LCD using 5k pot.
 

kobre98

Full Member level 2
Joined
Sep 18, 2011
Messages
145
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Location
Gaza, Palestine
Activity points
2,523
I did adjust the contrast of my LCD nothing happens, back to 4 mhz and it worked again !!

My LCD number is lmb204b

20 mhz crystal with 2 * 33pf capacitors
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
523
Trophy points
1,393
Activity points
0
Maybe your compiler is generating wrong .hex files. Please Zip and post the latest project files. Compile the code once before zipping it. I will check if your compiler is generating wrong .hex file. Compile for 20 MHz and post it.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top