krishnaraj.jadav
Newbie level 2
- Joined
- Mar 12, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- rajkot
- Activity points
- 1,297
I am using 89v51rd2 NXP controller.I prepared whole circuit but when i run my circuit nothing happen.
I am confuse whether i used wrong port for pins.Please help me out from this problem
port 1 pins
rs-p1^0
e-p1^2
rw-ground
Port 2 pins
D0 to D7- port 2
View attachment lcd kraj.bmp
Code:
#include<reg51.h>
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
sbit RS=P1^0;
sbit E=P1^1;
void main(void)
{
lcdinit(); //Initilize LCD
writedata('k'); //write
writedata('r'); //write
writedata('i'); //write
writedata('s'); //write
writedata('h'); //write
writedata('n'); //write
writedata('a'); //write
writedata('r'); //write
writedata('a'); //write
writedata('j'); //write
while(1)
{
}
}
void writedata(char t)
{
RS = 1; // => RS = 1
P2 = t; //Data transfer
E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}
void writecmd(int z)
{
RS = 0; // => RS = 0
P2 = z; //Data transfer
E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}
void lcdinit(void)
{
writecmd(0x38); //function set
writecmd(0x0c); //display on,cursor off,blink off
writecmd(0x01); //clear display
writecmd(0x80);
writecmd(0x06); //entry mode, set increment
}
void delay(int a)
{
int i;
for(i=0;i<a;i++); //null statement
}
I am confuse whether i used wrong port for pins.Please help me out from this problem
port 1 pins
rs-p1^0
e-p1^2
rw-ground
Port 2 pins
D0 to D7- port 2
View attachment lcd kraj.bmp
Code:
#include<reg51.h>
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
sbit RS=P1^0;
sbit E=P1^1;
void main(void)
{
lcdinit(); //Initilize LCD
writedata('k'); //write
writedata('r'); //write
writedata('i'); //write
writedata('s'); //write
writedata('h'); //write
writedata('n'); //write
writedata('a'); //write
writedata('r'); //write
writedata('a'); //write
writedata('j'); //write
while(1)
{
}
}
void writedata(char t)
{
RS = 1; // => RS = 1
P2 = t; //Data transfer
E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}
void writecmd(int z)
{
RS = 0; // => RS = 0
P2 = z; //Data transfer
E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}
void lcdinit(void)
{
writecmd(0x38); //function set
writecmd(0x0c); //display on,cursor off,blink off
writecmd(0x01); //clear display
writecmd(0x80);
writecmd(0x06); //entry mode, set increment
}
void delay(int a)
{
int i;
for(i=0;i<a;i++); //null statement
}