Monday, 21 September 2015

16X2 LCD (LM016L) Programming in ARM7(LPC2138) (display the message "hello world")

#include<lpc21xx.h>
void delay();
void cmd1(int);
void data(char);
void display(const char *p)
{
while(*p)
data(*p++);
}
int main()
{
IO1DIR=0XFFFFFFFF;
cmd1(0x38);
cmd1(0x01);
cmd1(0x06);
cmd1(0x0e);
cmd1(0x80);

display("hello world");
while(1);
}

void cmd1(int a)
{
IO1SET=a<<20;
IO1CLR=0X000F0000;
IO1SET|=0X00080000;
delay();
IO1CLR=0X00080000;
IO1CLR=0XFFFFFFFF;

}
void data(char a)
{
IO1SET=a<<20;
IO1CLR=0X000F0000;
IO1SET|=0X000A0000;
delay();
IO1CLR=0X00080000;
IO1CLR=0XFFFFFFFF;

}
void delay()
{
int i;
for(i=0;i<1000000;i++);
}

No comments:

Post a Comment