LCD not working!

20 replies [Last post]
rohan
Offline
Last seen: 5 years 32 weeks ago
Joined: 2009-05-03
bOt Points: 54

My 16x2 LCD is not working.. Wot should i do? some1 help me out!

shobhitkukreti
Offline
Last seen: 4 years 37 weeks ago
Joined: 2009-04-28
bOt Points: 683
The most basic issue is loose

The most basic issue is loose connecctions. If that is ok, check the contrast of LCD and vary it.Check your delays, the controller of LCD mite be busy while you sent other command/data. Increase the delay. A schematic of your connection and the program code will make it a little easier to decipher your problem. So post that as well

heloitsadi
Offline
Last seen: 5 years 18 weeks ago
Joined: 2009-03-15
bOt Points: 1321
LCD program

I am interfacing 16x2 LCD with Atmega16 controller, i wrote the code which works very fine when checked in AVR Studio simulator, but didn't work on my circuit, my circuit connections are perfectly ok and the LCD pannel is also tested, may be i am facing delay problem and could not initialise the LCD properly. Can anyone please post a working or tested code.

 

Regards:

Aditya Sharma

Robotics INDIA

bOtskOOl
Offline
Last seen: 4 years 39 weeks ago
Joined: 2009-02-21
bOt Points: 3500
Re: LCD not working!

As shobhitkukreti has said you should cross-check your connections again. Its the most common source of error. Also it will be better if you post your schematic/circuit diagram and program here. Have you tried running your program in a simulator?

bOtskOOl
Offline
Last seen: 4 years 39 weeks ago
Joined: 2009-02-21
bOt Points: 3500
Re: LCD program

Since your code is running properly in simulator it seems to be delay problem. Following points should be kept in mind while writing the progam - 

 

· The Enable pin is used by LCD to latch information present at its data pins. When data is supplied to data pins a high to low pulse of minimum 450 ns wide should be applied to En pin in order for LCD to latch in the data present at data pins.

 

· Also a delay of minimum 250ms between two simultaneous 'writing characters/moving cursors' commands.  

 

Have you implemented the above mentioned conditions?

 

heloitsadi
Offline
Last seen: 5 years 18 weeks ago
Joined: 2009-03-15
bOt Points: 1321
Yes I am faproblem setting

Yes I am faproblem setting the delay.

This is my code.. please can you help me correct it..

#define F_CPU 12000000ul //F_CPU value used in hardware 
#include <avr/io.h>
#include <util/delay. h>
#include<avr/delay.h>

#define dataport PORTC
#define commport PORTD
#define rs PD4
#define wr PD5
#define en PD6

int LCD_init(void) ;
int LCD_SendData(void);
int wrcomm(void) ;
int wrdata(void) ;

int main(void)
{
    DDRC = 0xFF;
    //PORTC=0x00;
    DDRD = 0x70;
    //PORTD=0x00;
    LCD_init();
    LCD_SendData();
    return 1;
}

int LCD_init()
{
    dataport = 0x38;    //init. LCD 2 lines, 5x7 matrix
    wrcomm();            //Right the command byte to command register
    dataport = 0x01;    //Clear LCD
    wrcomm();            //Right the command byte to command register
    dataport = 0x0E;    //Display on Cursor Blinking
    wrcomm();            //Right the command byte to command register
    dataport = 0x80;    //Cusor at line 1, position 1
    wrcomm();            //Right the command byte to command register
    dataport = 0x1C;    //Shift Entire Display To Right
    wrcomm();            //Right the command byte to command register

    return 1;
}

/*********** **** <<Sending Data To LCD Display>> ************ ***/
int LCD_SendData(void)
{
    unsigned char j[] = "LCD Display";
    int i;
    for(i = 0; i < sizeof j ; i++)
    {
        dataport = j[i];
        wrdata();
    }
    return 1;
}

/******* <<Righting the command byte to command register>> ********/
int wrcomm(void)
{
    commport &= ~(1 << rs);
    commport &= ~(1 << wr);
    commport |= (1 << en);
    commport &= ~(1 << en);
    _delay_ms(10) ;
    return 1;
}

/********** <<Righting the Data byte to Data register>> **********/
int wrdata(void)
{
    commport |= (1 << rs);
    commport &= ~(1 << wr);
    commport |= (1 << en);
    commport &= ~(1 << en);
    _delay_ms(10) ;
    return 1;
}   
 

shobhitkukreti
Offline
Last seen: 4 years 37 weeks ago
Joined: 2009-04-28
bOt Points: 683
Did you check the contrast

Did you check the contrast setting on the LCD ??

Pratik Panchal (not verified)
Have you provided a variable

Have you provided a variable resistor on contrast control pin? see that this pin does not get directly Vcc or ground. the best idea is to connect the variable terminal of 10k resistor to the contrast control pin. the other two terminals or variable resistor goes to vcc and ground. run the code and adjust the variable resistor so that you can see the characters on LCD.

heloitsadi
Offline
Last seen: 5 years 18 weeks ago
Joined: 2009-03-15
bOt Points: 1321
I got the mistake.. I was

I got the mistake.. I was using PORTC of uc as the output port without disabling the JTAG interface.. Now i am using PORTB for the output port.. The above code is working absolutely fine.. thanks to u all for your valuable suggestions..

shobhitkukreti
Offline
Last seen: 4 years 37 weeks ago
Joined: 2009-04-28
bOt Points: 683
Hmm, yes this happend with

Hmm, yes this happend with PICs as well, i have not been able to work with AVR/s though

heloitsadi
Offline
Last seen: 5 years 18 weeks ago
Joined: 2009-03-15
bOt Points: 1321
Can anybody tell me how to

Can anybody tell me how to disable the JTAG interface of PORTC in Atmega16/32 microcontrollers.

shobhitkukreti
Offline
Last seen: 4 years 37 weeks ago
Joined: 2009-04-28
bOt Points: 683
I thought you did it already.

I thought you did it already. It should be in the data sheet

heloitsadi
Offline
Last seen: 5 years 18 weeks ago
Joined: 2009-03-15
bOt Points: 1321
I am new to all these, so

I am new to all these, so didn't have so much knowledge in deep about AVR.. still learning.

heloitsadi
Offline
Last seen: 5 years 18 weeks ago
Joined: 2009-03-15
bOt Points: 1321
Please if anybody can reply

Please if anybody can reply to my query...botskool please answer it... i need to know about it.

bOtskOOl
Offline
Last seen: 4 years 39 weeks ago
Joined: 2009-02-21
bOt Points: 3500
Re: Can anybody tell me how to

JTAG can be disabled in many ways.

You can change the fuse-bit settings using an ISP programmer. 

An IO control bit "JTD" is available. Unlike the fuses this bit can be set at run-time allowing you to disable the JTAG / OCD functionality in software during program execution.

To disable JTAG you need to write to the MCUCSR and that too twice and also it must be done within four clock cycles or it won't stick.

MCUCSR=0x80;

MCUCSR=0x80;

Make sure you include avr/io.h header file.

 

You can also change fuse-bit settings by using ponyprog.

You need to check the box for JTAGEN fuse in that. 

Programmed fuse = 0 = checked

 

You can use Engbedded Atmel AVR® Fuse Calculator. This calculator will give you proper command line to execute in avrdude after you have selected appropriate settings.

 

 

 

heloitsadi
Offline
Last seen: 5 years 18 weeks ago
Joined: 2009-03-15
bOt Points: 1321
Thanl you very much.. Iwill

Thanl you very much.. Iwill try these things

reepjyoti
Offline
Last seen: 4 years 8 weeks ago
Joined: 2009-06-13
bOt Points: 66
its not clear to me.. can you

its not clear to me.. can you plz xplain it a little more..

reepjyoti
Offline
Last seen: 4 years 8 weeks ago
Joined: 2009-06-13
bOt Points: 66
can we manually change the

can we manually change the values of high and low fuse bits to 0xE1 and 0xD9 respectively?? will it work?? i found the values using the fuse bit calculator...

sharang
Offline
Last seen: 5 years 16 weeks ago
Joined: 2009-06-15
bOt Points: 66
blocks on the lcd
#include <reg51.h>
#include <absacc.h>
unsigned char hr,min,sec;
void bcdconv(unsigned x);
void serial(unsigned x);
sbit RS = P2^2;
sbit DS= P3^7;
sbit RW1= P3^6;
void print(unsigned char *ch);
sbit RW = P2^3;
sbit E = P2^4;
void put (unsigned char ch,bit rs);
void clear(void);
void delay(unsigned int);
void display();
void initlcd(void);
void print(unsigned char *ch);
void main(void)
{
delay(200);
initlcd();
XBYTE[10]=0x20;
XBYTE[11]=0x83;
XBYTE[0]= 0x55;
XBYTE[2]=0x58;
XBYTE[4]=0x16;
XBYTE[7]=0x19;
XBYTE[8]=0x10;
XBYTE[9]=0x04;
XBYTE[11]=0x03;
 
TMOD=0X20;
TH1=0XFD;
SCON=0x50;
TR1=1;
while(1)
{
hr=XBYTE[4];
bcdconv(hr);
serial(':');
min=XBYTE[2];
bcdconv(min);
serial(':');
sec=XBYTE[0];
bcdconv(sec);
serial(0x0D);
serial(0x0A);
}
display();
}
void bcdconv(unsigned mybyte)
{
unsigned char x,y;
x=mybyte&0XF0;
x=x|0x30;
y=mybyte&0XF0;
y=y>>4;
y=y|0x30;
serial(y);
serial(x);
}
void serial(unsigned x)
{
SBUF=x;
while(TI==0);
TI=0;
}
void put (unsigned char ch,bit rs)
{
E=1;
RW=0;
P0=ch;
RS=rs;
delay(100);
E=0;
delay(100);
RW=1;
return;
}
void clear(void)
  {
  put(0x01,0);
  delay(100);
  return;
  }
     
   void delay(unsigned int t)
  {
  unsigned int k,l;
  for(l=0;l<t;l++)
  for(k=0;k<1275;k++);
  return;   
  }
  void initlcd(void)
  {
  delay(250);
  put(0x38,0);
  delay(250);
  put(0x0E,0);
  delay(250);
  put(0x10,0);
  delay(250);
  put(0x01,0);
  delay(250);
  put(0x06,0);
 delay(250);
  //put(0x0C,0);
  print("RTC");
  delay(100);
  return;
  }
  void display()
  {
  
  put(hr,1);
  delay(1);
  clear();
  put(min,1);
  delay(1);
  clear();
  put(sec,1);
  delay(1);
  clear();
  }
  void print(unsigned char *ch)
{
while(*ch)
{
    put(*ch,1);
//put(0x10,0);
ch++;
}
  return;
  }
 

Sir here is the code i am using to interface lcd to 8052. All i am getting is blocks on lcd. 

 

code also include rtc 12887 interfacing

 

 

 

robo.genius
Offline
Last seen: 1 year 20 weeks ago
Joined: 2009-04-12
bOt Points: 265
sharang did u try changing

sharang did u try changing the potentiometer which changes contrast? Its probably contrast problem

kapil
Offline
Last seen: 3 years 39 weeks ago
Joined: 2010-02-24
bOt Points: 222
lcd not working in Atmega32

 I made the circuit properly and check the connection 2 tyms but lcd don't dispaly anything..only light is glowing...m using circuit and code given at this link

http://robozeal.blogspot.com/2009/08/lcd-interfacing-with-atmega16.html

plz help me....