Hi everyone,
I am interfacing lcd (JHD 162A) using 8051(89c51). The lcd's lamp only lit up otherwise nothing is displaying on the lcd.
here is the link to lcd datasheet:
http://www.egochina.net.cn/eBay/Download/JHD162A.pdf
i have checked all the connections to the lcd and they are good.
I wrote the code on keil uvision4
please tell me the problem!
your help is greatly appriciated
here is my code:
I am interfacing lcd (JHD 162A) using 8051(89c51). The lcd's lamp only lit up otherwise nothing is displaying on the lcd.
here is the link to lcd datasheet:
http://www.egochina.net.cn/eBay/Download/JHD162A.pdf
i have checked all the connections to the lcd and they are good.
I wrote the code on keil uvision4
please tell me the problem!
your help is greatly appriciated
here is my code:
Rich (BB code):
#include<regx51.h>
void lcdmd(unsigned char value);
void lcddata(unsigned char value);
void busyflag();
void delay(unsigned char value);
sbit rs=P2^0;
sbit rw=P2^1;
sbit e=P2^2;
sbit busy=P1^7;
sfr ldata=0x90;
int main(){
P0_2=0; //just for checking
//initilization
//step 1
delay(20);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=1;
P1_4=1;
e=1;
delay(200);
e=0;
//step 2
delay(10);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=1;
P1_4=1;
e=1;
delay(200);
e=0;
//step 3
delay(200);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=1;
P1_4=1;
e=1;
delay(200);
e=0;
//step 4
delay(100);
busyflag();
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=1;
P1_4=0;
e=1;
delay(200);
e=0;
delay(100);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=1;
P1_4=0;
e=1;
delay(200);
e=0;
// lines and font
delay(100);
rs=0;
rw=0;
P1_7=1;
P1_6=0;
P1_5=0;
P1_4=0;
e=1;
delay(200);
e=0;
delay(100);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=0;
P1_4=0;
e=1;
delay(200);
e=0;
delay(100);
rs=0;
rw=0;
P1_7=1;
P1_6=0;
P1_5=0;
P1_4=0;
e=1;
delay(200);
e=0;
delay(100);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=0;
P1_4=0;
e=1;
delay(200);
e=0;
delay(100);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=0;
P1_4=1;
e=1;
delay(200);
e=0;
delay(100);
rs=0;
rw=0;
P1_7=0;
P1_6=0;
P1_5=0;
P1_4=0;
e=1;
delay(200);
e=0;
// I/D S
delay(100);
rs=0;
rw=0;
P1_7=0;
P1_6=1;
P1_5=1;
P1_4=1;
e=1;
delay(200);
e=0;
P0_3=0; //just for checking
//initilization ends
lcdmd(0x0E);
lcdmd(0x06);
lcddata('P');
lcddata('h');
lcddata('a');
lcddata('s');
lcddata('e');
lcddata('1');
lcdmd(0xC0);
lcddata('P');
lcddata('h');
lcddata('a');
lcddata('s');
lcddata('e');
lcddata('2');
while(1){
if(P3_1==0){
lcddata(' ');
lcddata('o');
lcddata('n');
}
else{
lcddata(' ');
lcddata('o');
lcddata('f');
lcddata('f');
}
if(P3_0==0){
lcdmd(0x86);
lcddata(' ');
lcddata('o');
lcddata('n');
}
else{
lcdmd(0x86);
lcddata(' ');
lcddata('o');
lcddata('f');
lcddata('f');
}
}
return 0;
}
void lcdmd(unsigned char value){
busyflag();
ldata=value;
rs=0;
rw=0;
e=1;
delay(200);
e=0;
return;
}
void lcddata(unsigned char value){
busyflag();
ldata=value;
rs=1; //data register
rw=0; //write
e=1;
delay(200);
e=0;
return;
}
void busyflag(){
rs=0;
rw=1;
busy=1; //input
while(busy==1){
e=0;
delay(200);
e=1;
}
return;
}
void delay(unsigned char value){
unsigned int i,j;
for(i=0;i<value;++i)
for(j=0;j<1275;++j);
}
Last edited by a moderator: