Microcontroller › AVR › problem regarding interfacing LCD using ATMEGA16 code by CHINMAY CHINARA
- This topic has 4 replies, 4 voices, and was last updated 13 years, 2 months ago by
Sagar.
-
AuthorPosts
-
July 11, 2011 at 5:45 am #1067
query
ParticipantI am using the JHD162A LCD and based on the tutorial code.The connections are made as per the tutorial circuit diagram. But instead of showing an ‘A’ on the screen what I see is the backlit display is on and the first line of the screen is filled with black squares. Even if I increase or decrease the contrast pot only the black sqares become dark or light and no other output is obtained. Kindly help me out with it.
July 23, 2011 at 6:15 am #6503dagakshay
Participantthis sounds some loose connection problem…
December 5, 2011 at 5:10 pm #6910Tuhin
ParticipantYou have made a worng connection. Just see the back sibe of LCD and conform which pin is no1. and so on. Then connect it. I myself suffered from this problem.I’m giving you the pin configration of LCD you connect it as per your requirment.
1.GND
2.VDD(5V or 3V)
3.V0(Contrast adjustment)
4.RS
5.R/W
6.EN
7.DB0
8.DB1
:
:
:
14.DB7
15.LED+(~ 4.2V)
16.LED-(GND)
Just see the backside of lcd and make sure your connection is right or not.
December 6, 2011 at 9:40 am #6912Sagar
Participantm having same problem with JHD162A ATmega16
heres the code…
//#define F_CPU 16000000
#include <avr/io.h>
//#include <util/delay.h>#define lcd_data PORTB
/*
PD.0=rs
PD.1=rw
PD.2=en*/
void lcdbusy() //function to monitor d7th bit (busy flag)
{
DDRB=0x7f;// this will make msb of portb to inputPORTD=0xfe;// rs=0 rw=1 en=1, rw=1->read from lcd
while(PINB>>7) //move the msb to lsb
{PORTD |=0x04; //en-> from low to high
PORTD &=0xfb; //en-> from high to low
}DDRB=0xff;//make PORTB for output
}
void initlcd()
{
DDRD=0xff; //PORTD as output
DDRB=0xff; //portb as output
lcd_data=0x38; //8 bit,5×7 dots
PORTD=0xfc; //rs=0 rw=0 en=1, 0xfc where c=1100
PORTD=0xf8; //rs=0 rw=0 en=0, 0xf8 where 8=1000, frm en->high to lowlcdbusy(); // w8 b4 executing next command
lcd_data=0x0f; //cursor blinking display on
PORTD=0xfc;
PORTD=0xf8;lcd_data=0x01; // clear lcd
PORTD=0xfc;
PORTD=0xf8;lcdbusy();
lcd_data=0x06; //entry mode
PORTD=0xfc;
PORTD=0xf8;lcdbusy();
}void lcdcmd(unsigned char ch)
{
lcd_data=ch;
PORTD=0xfc;
PORTD=0xf8;lcdbusy();
}void lcdchar(unsigned char ch)
{
lcd_data=ch;
PORTD=0xfd; // 0xfd where d=1101 rs=w rw=0 en=1
PORTD=0xf9; //9=1001 rs=1 rw=0 en=0, en-> from high to low
lcdbusy();
}void lcdstring(char *str)
{
while(*str)
{
lcdchar(*str);
str++;
}
}int main()
{
initlcd();
lcdcmd(0x80);// move cursor to 1st line 1st column
lcdstring(“Welcome ATmega16 !”);while(1);
return 0;
}
m i missing something ?
December 6, 2011 at 1:34 pm #6913Sagar
Participanthey guys solved my problem…. !
this is wat i did.
added little delay betwn two instruction of enable pin.
@query : add _delay_ms(1); after each high to low pulse for enable pin.
surely this will work for you.
-
AuthorPosts
- You must be logged in to reply to this topic.