Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

[SOLVED] LCD with PIC16F877A problem

Status
Not open for further replies.

kobre98

Full Member level 2
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.
 

Post the configuration details here...
 

pic16f877.JPG

As attached image
 

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.
 

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.
 

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

  • __Lib_LCD_4bit_16x2_20x2_20x4.rar
    950 bytes · Views: 82

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
 

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.
 

Thanks a lot attached my project files
 

Attachments

  • Height and Weight Machine.rar
    22 KB · Views: 68
  • lcd.rar
    15.1 KB · Views: 64

Here is the fixed code. Hope it solves your problem.
 

Attachments

  • Height and Weight Machine.rar
    27.5 KB · Views: 72

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?!
 

I have just used


Code C - [expand]
1
TRISB = 0x00



You should use HD44780 or compatible LCDs.
 

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
 

Maybe an issue with Ceramic Capacitor values used for Oscillator Circuit.
 

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?
 

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.
 

It didn't work !
I really don't know what is the problem
this is frustrating
 

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.
 

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
 

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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top