这是一个液晶程序的底层驱动的几个函数,原来在51中可以正常工作,移植到LPC2114上却不行了. 它是16位数据方式,在51中P1输出高8位,P0输出低8位, 在2114中P0.0~P0.15为数据,P0.16~20为控制信号
#define LCD_RST (1<<20) //复位 #define LCD_RD (1<<19) //读 #define LCD_WR (1<<18) //写 #define LCD_RS (1<<17) //命令 #define LCD_CE (1<<16) //片选
/******************DRIVE IC寄存器寻址 8080 SERIES*******************************/ void write_command(uint8 addr1,uint8 addr2) { IO0CLR = LCD_RS; //rs=0; IO0CLR = LCD_CE ; //ce=0; IO0SET = LCD_RD; //rd=1; //OutData((addr1<<8)+addr2); IO0CLR = 0xffff; IO0SET = (addr1<<8)&0xff00; //p1=dat1; IO0SET = addr2 & 0xff; //p0=dat2; IO0CLR = LCD_WR; //wr=0; IO0SET = LCD_WR; //wr=1; IO0SET = LCD_CE; //ce=1; }
/*****************DRIVE IC寄存器写数据 8080 SERIES******************************/ void write_para(uint8 para1,uint8 para2) { IO0SET = LCD_RS; //rs=1; IO0CLR = LCD_CE ; //ce=0; IO0SET = LCD_RD; //rd=1; //OutData((para1<<8)+para2); IO0CLR = 0xffff; IO0SET = (para1<<8)&0xff00; //p1=para1; IO0SET = para2 & 0xff; //p0=pata2; IO0CLR = LCD_WR; //wr=0; IO0SET = LCD_WR; //wr=1; IO0SET = LCD_CE; //ce=1 } /****************DRIVE IC GDRAM 写数据 16BITS 8080 SERIES*****************************/ void write_data(uint8 dat1,uint8 dat2) { IO0SET = LCD_RS; //rs=1; IO0CLR = LCD_CE ; //ce=0; IO0SET = LCD_RD; //rd=1; //OutData((dat1<<8)+dat2); IO0CLR = 0xffff; IO0SET = (dat1<<8)&0xff00; //p1=dat1; IO0SET = dat2 & 0xff; //p0=dat2; IO0CLR = LCD_WR; //wr=0; IO0SET = LCD_WR; //wr=1; IO0SET = LCD_CE; //ce=1 } |