1LCD12864驱动程序(带字库的),本人亲自调试过。//液晶LCD12864驱动程序,可流水显示汉字#includereg52.h#defineucharunsignedchar#defineuintunsignedint#defineDataPortP0#defineN800sbitRS=P2^0;sbitRW=P2^1;sbitE=P2^2;sbitPSB=P2^3;intnum;uinti=0;uintl=0;uintb;uchara[]=我爱我家09abcdefg,今天是2010年08月09日星期三太热了!~_~;uchard[]={0x98,0x90,0x88,0x80};/**************延时1ms*count*****************/voiddelay(intcount){intx,y;for(x=0;xcount;x++)for(y=0;y120;y++);}/**************延时1us***********************//*voiddelayuS(ucharbuf){while(buf--);}*//***********忙检测********************/voidBusy(){DataPort=0xFF;RS=0;RW=1;while(1){E=1;if(P0^7==0)break;}E=0;}/***********写指令子程序****************/2voidWrite_Com(ucharcommand){Busy();//检测忙标志位RS=0;RW=0;DataPort=command;//写入指令E=1;delay(1);E=0;}/***********写数据子程序***************/voidWrite_Data(ucharData){Busy();RS=1;RW=0;DataPort=Data;E=1;delay(1);E=0;}/***********LCD初始化*******************/voidInit_LCD(void){PSB=0;delay(1);PSB=1;//将PSB置1,通信方式为8位数据并口delay(1);Write_Com(0x30);//30H--基本指令操作Write_Com(0x0c);//开显示,关光标,不闪烁。Write_Com(0x01);//清除显示Write_Com(0x02);Write_Com(0x06);//指定在资料写入或读取时,光标的移动方向,DDRAM的地址计数器(AC)加1。Write_Com(0x04);//显示状态全关}/*****************清屏***********************/voidClear_LCD(void){Write_Com(0x01);Write_Com(0x34);Write_Com(0x30);}/******************读地址*************************************/3/*voidRead_Add(void){//ucharadd=0;DataPort=0xFF;RS=0;RW=1;Busy();add=(DataPort|0x10)&0xbf;//return(add);}*///读地址失败/*****************判断行*******************//*voidLine_Num(uchark){//uintl;if(k=128&&k=135)l=1;if(k135&&k=143)l=3;if(k143&&k=151)l=2;if(k151&&k=159)l=4;}*//*******************逐行显示***************************************/voidDisplay_Line(ucharx){ucharc=0;c=x-0x1;//本函数说明,函数内部的计算公式一定要处在函数的首行if(i==0)Write_Com(x);if(i==2*(0x87-c))Write_Com(0x90);if(i==2*(0x97-c))Write_Com(0x98);if(i==2*(0x8f-c))Write_Com(0x88);}/*voidScan_Line(void){if(i==14)Write_Com(0x90);if(i==30)Write_Com(0x88);if(i==45)Write_Com(0x98);}*/voidShow_Chiese(){EA=0;b=sizeof(a);num=b;for(l=0;l4;l++){for(i=0;inum;i++){4Display_Line(d[l]);Write_Data(a[i]);}delay(N);//EA=1;}EA=1;TH0=0x06;TL0=0x06;Clear_LCD();delay(500);}voidmain(void){TMOD=0x01;///选择定时器模式TR0=1;//开中断,并允许T0中断ET0=1;EA=1;//总开关Init_LCD();Clear_LCD();while(1);}voidt0(void)interrupt1using0{//delay(100);Show_Chiese();//EA=0;}