hashim5003
Junior Member level 2
- Joined
- Jul 21, 2013
- Messages
- 21
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 3
- Activity points
- 116
I am interfacing at89s52 with 16*2 lcd. Problem is that lcd don't shows the character that I have written in the code. it shows some random character or weird character. Plz chk my code if it's correct or not:
Code:
#include<reg52.h>
sfr ldata=0x90;
sbit rs=P3^7;
sbit rw=P3^6;
sbit en=P3^5;
void delay()
{
TMOD = 0x01;
TH0 = 0x00;
TL0 = 0x00;
TR0 = 1;
while (TF0==0);
TF0 = 0;
TR0 = 0;
}
void lcdcmd(unsigned char u)
{
ldata=u;
en=1;
rs=0;
rw=0;
delay();
en=0;
delay();
}
void lcddata(unsigned char v)
{
ldata=v;
en=1;
rs=1;
rw=0;
delay();
en=0;
}
void lcdini()
{
delay();
lcdcmd(0x30);
delay();
delay();
lcdcmd(0x30);
delay();
delay();
lcdcmd(0x30);
delay();
lcdcmd(0x38);
delay();
lcdcmd(0x0c);
delay();
lcdcmd(0x80);
delay();
}
void main()
{
lcdini();
lcddata('A');
delay();
lcddata('B');
delay();
lcddata('C');
delay();
while(1);
}