新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 不帶字庫的128*64液晶漢字顯示程序

不帶字庫的128*64液晶漢字顯示程序

作者: 時間:2012-08-25 來源:網(wǎng)絡 收藏

下面是線路連接圖,我自己已經(jīng)搞了整整一個測試成功了絕對可用
點擊瀏覽下一頁

由于篇幅有限完整的c51代碼下載:http://www.51hei.com/f/12864wu.rar

源代碼:#includereg52.h>#define LCD P0unsigned char i,j,k;sbit EN=P2^0;sbit RW=P2^1;sbit RS=P2^2;sbit CS1=P2^3;sbit CS2=P2^4;sbit BUSY=P0^0;void delay(unsigned char a);unsigned char code ban[16][16]={{0x00,0x00,0x00,0xf0,0x90,0x90,0x90,0xfe,0x90,0x90,0x90,0xf0,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x3f,0x24,0x24,0x24,0x27,0x20,0x38,0x00,0x00},//電{0x00,0x00,0x00,0x00,0x8c,0x88,0x88,0x88,0x88,0xc8,0xa8,0x98,0x00,0x00,0x00,0x00},{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//子{0x00,0x00,0x00,0x00,0x10,0x10,0x30,0x54,0x9c,0x90,0x50,0x00,0x30,0x10,0x00,0x00},{0x00,0x40,0x30,0x0c,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00},//產(chǎn){0x00,0x00,0x00,0x00,0x7c,0x44,0x44,0x44,0x44,0x44,0x44,0x7c,0x00,0x00,0x00,0x00},{0x00,0x00,0x3f,0x21,0x21,0x21,0x3f,0x00,0x00,0x3f,0x21,0x21,0x21,0x3f,0x00,0x00},//品{0x00,0x00,0x00,0x00,0x0c,0x08,0x08,0x08,0xf8,0x08,0x08,0x08,0x08,0x00,0x00,0x00},{0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x3f,0x20,0x20,0x20,0x20,0x30,0x00,0x00},//工{0x00,0x90,0x90,0x88,0xf8,0x84,0x86,0x00,0x7c,0x44,0x44,0x44,0x44,0x7c,0x00,0x00},{0x40,0x30,0x0c,0x02,0x7f,0x02,0x0c,0x10,0x49,0x49,0x49,0x7f,0x49,0x49,0x00,0x00},//程{0x00,0x10,0x10,0x10,0xfc,0x90,0x10,0x00,0xd0,0x50,0x50,0x7e,0x50,0xd0,0x50,0x00},{0x04,0x08,0x04,0x22,0x7f,0x00,0x40,0x20,0x10,0x09,0x06,0x06,0x09,0x10,0x20,0x40},//技{0x00,0x00,0x10,0x10,0x10,0xd0,0x10,0xfe,0x10,0x50,0x94,0x1c,0x10,0x00,0x00,0x00},{0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x7f,0x00,0x00,0x00,0x03,0x04,0x18,0x60,0x00},//術  };unsigned char code qrs[6][16]={{0x00,0x00,0xbc,0xe0,0xa0,0xa0,0xe0,0xa0,0x3f,0xa0,0x60,0x20,0x20,0x3c,0x00,0x00},{0x00,0x00,0x00,0x3f,0x24,0x24,0x3f,0x22,0x11,0x09,0x05,0x07,0x09,0x13,0x20,0x00},//嵌{0x00,0x00,0x00,0x00,0x02,0x04,0xc8,0x30,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00},{0x00,0x40,0x20,0x18,0x06,0x01,0x00,0x00,0x00,0x00,0x00,0x03,0x06,0x0c,0x30,0x00},//入--{0x00,0x00,0x00,0x20,0xa0,0xa0,0xa0,0xa0,0xa2,0xa4,0x38,0xe0,0x24,0x2c,0x00,0x00},{0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x0f,0x09,0x04,0x04,0x00,0x07,0x18,0x20,0x00},//式};checkbusy(){ EN=1;RW=1;RS=0;LCD=0XFF;if(BUSY);}writecode(unsigned char dat)  //寫命令{ checkbusy();EN=1;RW=0;RS=0;LCD=dat;EN=1;EN=0;}writedata(unsigned char dat)  //寫數(shù)據(jù){ checkbusy();EN=1;RW=0;RS=1;LCD=dat;EN=1;EN=0;}void displayhanzi(unsigned char page,unsigned char lineaddress,int n,  unsigned char table[][16]){unsigned char  temp[32];if(lineaddress0X80){CS1=1;CS2=0;}//leftfor(j=0;jn;j++){ if(lineaddress>=0X80){CS1=0;//rightCS2=1;lineaddress=lineaddress-0X40;}////////////////////////////////////////for(k=0;k16;k++){temp[k]=table[j][k];}j+=1;for(k=0;k16;k++){temp[16+k]=table[j][k];}     //一個字:占兩個字符,32個數(shù)據(jù)(temp[32])///////////////////////////////////////writecode(page);writecode(lineaddress);for(i=0;i16;i++){ writedata(temp[i]);}writecode(page+1);writecode(lineaddress);for(i=16;i32;i++){ writedata(temp[i]);}   //寫一個字:每頁16個數(shù)據(jù)////////////////////////////////////////////////lineaddress+=16;delay(200);}}void clear(){unsigned char b=0x40,c,d;for(c=0;c4;c++){for(a=0;a8;a++){switch(c){case 0:d=0xb8;break;case 1:d=0xba;break;case 2:d=0xbc;break;default:d=0xbe;}displayhanzi(d,b,2,lin);b+=0x10;} b=0x40; }}void lcdinti(){     writecode(0X3f);//顯示開關關writecode(0XC0);//修改顯示起始行writecode(0XB8);//修改頁地址,x地址writecode(0X40);//修改列地址,y地址}void delay(unsigned char a){unsigned char i,j;for(i=0;ia;i++)for(j=0;j200;j++);}main(){ lcdinti();clear();while(1){displayhanzi(0XB8,0X40,12,xx);displayhanzi(0XBa,0X40,16,ban);displayhanzi(0XBc,0X60,6,zjy);displayhanzi(0XBe,0X60,6,qrs);delay(200);clear();displayhanzi(0XB8,0X40,12,xx);displayhanzi(0XBa,0X40,16,ban);displayhanzi(0XBc,0X60,4,sg);displayhanzi(0XBe,0X60,6,qrs);delay(200);clear();displayhanzi(0XB8,0X40,12,xx);displayhanzi(0XBa,0X40,16,ban);displayhanzi(0XBc,0X60,6,qrs);displayhanzi(0XBe,0X60,8,jqyk);      delay(200);delay(200);delay(200);delay(200);delay(200);delay(200);delay(200);delay(200);clear();}}匯編源代碼:完整代碼下載:http://www.51hei.com/f/12864wuasm.rarORG 0100HEN  BIT  0A0H       ;sbit EN=P2^0;  RW  BIT  0A1H       ;sbit RW=P2^1;RS  BIT  0A2H       ;sbit RS=P2^2;CS1 BIT  0A3H       ;sbit CS1=P2^3;CS2 BIT  0A4H BUS BIT 80HSTART:CLR   CS1CLR   CS2 CALL  INITCALL  CLEARCALL  HANZI  SJMP  $WRITEDATA:        ;入口參數(shù)R1PUSH  PSWPUSH  ACCSETB ENCLR  RWSETB RSNOPMOV  P0,R1 NOP       SETB ENNOPNOPCLR  ENPOP   ACCPOP   PSWRETWRITECODE:       ;入口參數(shù)R2PUSH  PSWPUSH  ACCSETB  ENCLR   RWCLR   RSNOPMOV   P0,R2NOPSETB  ENNOPNOPCLR   ENPOP   ACCPOP   PSWRETDELAY:            ;入口參數(shù)R2PUSH  PSWPUSH  ACCMOV   R1,0FFH A2:   DEC   R2 A1:   DEC   R1 DJNZ  R1,A1DJNZ  R2,A2POP   ACCPOP   PSWRETINIT:PUSH  PSWPUSH  ACCMOV   R2,0C0HCALL  WRITECODEMOV   R2,3FHCALL  WRITECODEMOV   R2,0BBHCALL  WRITECODEMOV   R2,50HCALL  WRITECODEPOP   ACCPOP   PSWRETCLEAR:PUSH  PSWPUSH  ACCCLR   CS1CLR   CS2MOV   R2,0B8HB2:MOV   31H,R2PUSH  31H CALL  WRITECODEMOV   R2,40HCALL  WRITECODEB1:   MOV   R1,#00HCALL  WRITEDATA INC   R2CJNE  R2,#80H,B1POP   31HINC   31HMOV   R2,31H CJNE  R2,#0BEH,B2 POP   ACCPOP   PSW RET HANZI:PUSH  PSWPUSH  ACCCALL  INITANL   A,#00HMOV   DPTR,#DATB3:MOVC  A,@A+DPTRMOV   R1,A CALL  WRITEDATA INC   R2INC   ACJNE  R2,#50H,B3MOV   R2,0B9HCALL  WRITECODEMOV   R2,40HCALL  WRITECODEB4:MOVC  A,@A+DPTRMOV   R1,A CALL  WRITEDATAINC   R2INC   ACJNE  R2,#50H,B4POP   ACCPOP   PSWRETDAT:DB  0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01DB  0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01     END

c++相關文章:c++教程




評論


相關推薦

技術專區(qū)

關閉