lulezo
Junior Member level 3
Hi guys
I am trying to interface LPC2148 with 16*2 LCD and I got nothing at all in the LCD, I don't know why, here is my code -I thought that it should work -
Note: Data connected to P0.19 P0.20 P0.21 P0.22
Enable P0.10
RS P0.13
RW P0.12
#include <LPC214X.H>
void cmd(unsigned char d);
void datal(unsigned char t);
void delay (int count);
int main()
{
IODIR0=0x00783400;
IOCLR0=0x00003400;
cmd(0x28 );
cmd(0x01);
cmd(0x02);
cmd(0x06);
cmd(0x0C);
cmd(0x80);
datal('U');
while(1);
}
void cmd(unsigned char d)
{
unsigned char a;
a=d&0xF0;
a=a<<15;
IOCLR0 = 0x00003000;
IOSET0 = 0x00000400;
IOCLR0 = 0x00780000;
IOSET0 = a;
delay(10000);
IOCLR0 = 0x00000400;
a=d&0x0F;
a=a<<19;
IOCLR0 = 0x00003000;
IOSET0 = 0x00000400;
IOCLR0 = 0x00780000;
IOSET0 = a;
delay(10000);
IOCLR0 = 0x00000400;
}
void datal(unsigned char t)
{
unsigned char b;
b=t&0xF0;
b=b<<15;
IOSET0 = 0x00002400;
IOCLR0 = 0x00780000;
IOSET0 = b;
delay(10000);
IOCLR0 = 0x00000400;
b=t&0x0F;
b=b<<19;
IOSET0 = 0x00002400;
IOCLR0 = 0x00780000;
IOSET0 = b;
delay(10000);
IOCLR0 = 0x00000400;
}
void delay(int count)
{
int j=0, i=0;
for (j=0;j<count;j++)
for (i=0;i<35;i++);
}
I am trying to interface LPC2148 with 16*2 LCD and I got nothing at all in the LCD, I don't know why, here is my code -I thought that it should work -
Note: Data connected to P0.19 P0.20 P0.21 P0.22
Enable P0.10
RS P0.13
RW P0.12
#include <LPC214X.H>
void cmd(unsigned char d);
void datal(unsigned char t);
void delay (int count);
int main()
{
IODIR0=0x00783400;
IOCLR0=0x00003400;
cmd(0x28 );
cmd(0x01);
cmd(0x02);
cmd(0x06);
cmd(0x0C);
cmd(0x80);
datal('U');
while(1);
}
void cmd(unsigned char d)
{
unsigned char a;
a=d&0xF0;
a=a<<15;
IOCLR0 = 0x00003000;
IOSET0 = 0x00000400;
IOCLR0 = 0x00780000;
IOSET0 = a;
delay(10000);
IOCLR0 = 0x00000400;
a=d&0x0F;
a=a<<19;
IOCLR0 = 0x00003000;
IOSET0 = 0x00000400;
IOCLR0 = 0x00780000;
IOSET0 = a;
delay(10000);
IOCLR0 = 0x00000400;
}
void datal(unsigned char t)
{
unsigned char b;
b=t&0xF0;
b=b<<15;
IOSET0 = 0x00002400;
IOCLR0 = 0x00780000;
IOSET0 = b;
delay(10000);
IOCLR0 = 0x00000400;
b=t&0x0F;
b=b<<19;
IOSET0 = 0x00002400;
IOCLR0 = 0x00780000;
IOSET0 = b;
delay(10000);
IOCLR0 = 0x00000400;
}
void delay(int count)
{
int j=0, i=0;
for (j=0;j<count;j++)
for (i=0;i<35;i++);
}