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.

16x2 LCD Working problem!

Status
Not open for further replies.

!Engineer!

Newbie level 3
Newbie level 3
Joined
May 4, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
I have taken a code from a book to display characters on LCD. I ran this code in proteus and it is working perfectly but when I ran it on hardware but it doesn't display anything on LCD except that the back light is on. I know proteus is not 100% correct for hardware. I have been debugging it since morning but nothing got solved. I check voltages, remade the circuit, checked all connections too. Now it's getting so frustrating! :( I am using pic18f4520 microcontroller and 16x2 LCD and the compiler is MPLAB. I am attaching my schematic and code here.

P.S. I have read many forums here and did everything, installed potentiometer in the circuits, resistors etc, did reset on the board, tried every possible thing but nothing happens!

This is the schematic :
https://obrazki.elektroda.pl/3234481400_1367694148.png

and here's the code :

#include<p18f4520.h>
#define ldata PORTD
#define rs PORTCbits.RC0
#define rw PORTCbits.RC1
#define en PORTCbits.RC2
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void MSDelay(unsigned int itime);

void main()
{
TRISD = 0;
TRISC = 0;
en = 0;
MSDelay(250);
lcdcmd(0x38);
MSDelay(250);
lcdcmd(0x0E);
MSDelay(15);
lcdcmd(0x01);
MSDelay(15);
lcdcmd(0x06);
MSDelay(15);
lcdcmd(0x80);
MSDelay(15);
lcddata('M');
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 int itime)
{
unsigned i,j;
for(i = 0; i<itime; i++)
for(j = 0; j<135; j++);
}
 

Attachments

  • proteus.png
    proteus.png
    49.4 KB · Views: 131

Proteus ISIS is not considering the configuration bits values, instead, it's using a configuration word set in the device settings which should work fine most of times; the real PIC though has to be properly configured during programming.
Include the configuration bits in your code (__CONFIG(WDT_OFF & LVP_OFF ect..)) right after the #include<p18f4520.h> line and make sure the programmer doesn't have any overriding values for the ones you set.
 
Proteus ISIS is not considering the configuration bits values, instead, it's using a configuration word set in the device settings which should work fine most of times; the real PIC though has to be properly configured during programming.
Include the configuration bits in your code (__CONFIG(WDT_OFF & LVP_OFF ect..)) right after the #include<p18f4520.h> line and make sure the programmer doesn't have any overriding values for the ones you set.


Okay thanks I am going to try that :) What do you mean by overriding values? Sorry I am using LCD first time so I don't know much.
 

In the circuit you show VEE tied high, it should be tied low for you to see anything on the LCD or better still connected to a 5K pot to ground with its wiper initially set to ground.
 

In the circuit you show VEE tied high, it should be tied low for you to see anything on the LCD or better still connected to a 5K pot to ground with its wiper initially set to ground.

I did that, as I mentioned earlier I tried everything, connected VEE to ground, Vcc, potentiometer, resistors etc but nothing happened...
 

with overriding values I mean that some programmers can write the configuration bits based on settings in the programmer itself, and totally ignoring the configuration bits set in the code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top