I wrote a program to display ‘a’ in a 2*16 lcd with datalines connected to p0.10 to p0.13 as datalines,p1.22 to p1.24 as control lines of lpc2148.Lcd has to be operated in 4 bit mode.The program is as follows(i use keil’s mdk):
#include<lpc21xx.h>
#define rs 1<<24
#define rw 1<<23
#define en 1<<22
//#define bzr 1<<25
#define dt (0XF)<<10
void cmd(unsigned char);
void dat(unsigned char);
void delay(void);
int main()
{
IODIR1=rs|rw|en;
IODIR0=dt;
cmd(0X2);
cmd(0X8);
cmd(0X0);
cmd(0XE);
cmd(0X0);
cmd(0X1);
cmd(0X0);
cmd(0X6);
cmd(0X8);
cmd(0X0);
dat(0X4);
dat(0X1);
while(1);
}
void cmd(unsigned char c)
{
IOCLR0=dt;
IOSET0=dt&(c<<10);
IOCLR1=rs|rw;
IOSET1=en;
delay();
IOCLR1=en;
delay();
}
void dat(unsigned char d)
{
IOCLR0=dt;
IOSET0=dt&(d<<10);
IOCLR1=rw;
IOSET1=rs|en;
delay();
IOCLR1=en;
delay();
}
void delay(void)
{
unsigned int i;
for(i=0;i<1000;i++);
}
There is no prob in the kit because i tried a program that one of my frien did and it worked out!!!i dont know wat is the prob wit my prog…any hlp???