ARM7嵌入式LPC21XX系列
程序员文章站
2022-06-08 21:44:52
...
LCD1602显示字符
仿真:
代码:
#include"config.h"
#define rs (1<<8)
#define rw (1<<9)
#define en (1<<10)
#define busy (1<<7)
uint8 txt[]="HELLO EVERYONE"; //14
uint8 txt1[]="welcome to here";//15
void ChkBusy()
{
IODIR=0x700;
while(1)
{
IOCLR =rs;
IOSET =rw;
IOSET =en;
if(!(IOPIN & busy))break;
IOCLR =en;
}
IODIR =0x7ff;
}
void WrOp(uint8 dat)//写指令
{
ChkBusy();
IOCLR =rs;
IOCLR =rw;
IOCLR =0xff;
IOSET =dat;
IOSET =en;
IOCLR =en;
}
void WrDat(uint8 dat)//写数据
{
ChkBusy();
IOSET =rs;
IOCLR =rw;
IOCLR =0xff;
IOSET =dat;
IOSET =en;
IOCLR =en;
}
void delay(uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
void lcdinit() //初始化
{
WrOp(0x38);
WrOp(0x06);
WrOp(0x01);
WrOp(0x0c);
}
int main()
{
uint8 i;
PINSEL0 =0x00000000;
PINSEL1 =0x00000000;
IODIR =0x7ff;
IOCLR =0x7ff;
lcdinit();
WrOp(0x80+0x10);
for(i=0;i<14;i++)
{
WrDat(txt[i]);
}
WrOp(0x80+0x50);
for(i=0;i<15;i++)
{
WrDat(txt1[i]);
}
for(i=0;i<16;i++)
{
WrOp(0x1c);
delay(5);
}
while(1);
return 0;
}
关注微信公众号“伊斯电子编程”获取更多资源
上一篇: oracle 更改数据库名的方法