12232 LCD PROTEUS仿真(51C)12232在proteus 里模型用关键字P ,“12232”查不出LCD的,要用1232 查找。
好不容易得到模型,编写程序,一直不能成功。
第一个字符正常,后面的就乱了。
最后才明白:12232的模型和实物不一样,共4页(这和实物一样),每页只能从地址0开始,水平方向从左往右显示。
另外,按实物的程序,仿真中显示是相反的,所以初始化时应改为反向显示,仿真显示才正常。
//12232LCD proteus仿真//2012 01 20 E:\DPJ_C\12232\12232UV4\12232_2C.C#include<reg51.h>#include<intrins.h>#include"chr16.h"#define uchar unsigned char#define uint unsigned int#define LCD_DB P0sbit E2=P3^5;sbit E1=P3^6;sbit A0=P3^7;void WR_Mcom(uchar i){E1=1;_nop_();A0=0;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E1=0;_nop_();_nop_();}void WR_Mdat(uchar i) {E1=1;_nop_();_nop_();A0=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E1=0;_nop_();_nop_();}void WR_Scom(uchar i) {A0=0;_nop_();_nop_();E2=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E2=0;_nop_();}void WR_Sdat(uchar i){A0=1;_nop_();_nop_();E2=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E2=0;_nop_();_nop_();}void lcdini(){WR_Mcom(0XE2);WR_Scom(0XE2);//WR_Mcom(0XAE);WR_Scom(0XAE);//显示开关:关WR_Mcom(0XA4);//动态显示WR_Scom(0XA4);//WR_Scom(0XA9);//1/32 占空比WR_Mcom(0XA1);WR_Scom(0XA1);WR_Mcom(0XEE);WR_Scom(0XEE);//写模式WR_Mcom(0X00);//起始列0WR_Mcom(0XC0);//起始行0WR_Scom(0X00);WR_Scom(0XC0);WR_Mcom(0XAF);WR_Scom(0XAF);//显示开关:开}void SetPage(uchar page0,uchar page1) {WR_Scom(0xB8|page0);}void SetAddress(uchar address0,uchar address1) {WR_Mcom(address1&0x7F);WR_Scom(address0&0x7F);}void clrscr( ){uchar i;uchar page;for (page=0;page<4;page++){SetPage(page,page);SetAddress(0,0);for (i=0;i<61;i++){WR_Mdat(0);WR_Sdat(0);}}}void display(){uchar i,j,page;for(page=0;page<4;page++){SetPage(page,page);SetAddress(0,0);for(i=0;i<4;i++){for(j=0;j<15;j++){if(page<2){WR_Mdat(chr16[2*i][j+page*15]);WR_Sdat(chr16[2*i+8][j+page*15]);}{WR_Mdat(chr16[2*i+16][j+(page-2)*15]);WR_Sdat(chr16[2*i+24][j+(page-2)*15]);}}}}}void main(){lcdini();clrscr();while(1){display();}}/**************************************************************************************** /CHR16.H //unsigned char code chr16[32][15]={{0x00,0x40,0x40,0xDA,0xFE,0x24,0x20,0xF8,0xDE,0xD6,0xD8,0xC8,0x48,0x00,0x00,},{0x08,0x0C,0x07,0x3F,0x3F,0x03,0x0F,0x1F,0x17,0xD5,0xFF,0x3F,0x11,0x11,0x01,},/*"梅",0*/{0x00,0x00,0x10,0x10,0x9C,0x9C,0x10,0x98,0x9E,0x0E,0x88,0x88,0x08,0x00,0x00,},{0x10,0x18,0x0C,0x7F,0x7F,0x08,0x08,0x3F,0x7F,0x43,0x41,0x40,0x78,0x38,0x00,},/*"花",1*/{0x00,0x00,0x20,0x20,0xE0,0xE0,0x60,0xFA,0xFE,0x24,0x60,0x60,0x20,0x00,0x00,},{0x00,0x10,0x19,0x0F,0x07,0x24,0x38,0x1F,0x07,0x0C,0x38,0x30,0x20,0x20,0x00,},/*"欢",2*/{0x00,0x00,0x00,0x08,0xA8,0xA8,0xFE,0x7E,0xEC,0xC4,0x44,0x00,0x00,0x00,0x00,},{0x08,0x08,0x08,0x08,0x6A,0xEF,0xAD,0xBD,0xD7,0x77,0x34,0x04,0x04,0x04,0x00,},/*"喜",3*/{0x00,0x40,0x40,0x18,0x98,0x84,0xFC,0xFC,0xEC,0xFE,0xDE,0xC4,0x40,0x00,0x00,},{0x00,0x10,0x3C,0x3E,0x42,0x45,0x6D,0x3D,0x1F,0x3F,0x63,0x60,0x40,0x40,0x40},/*"漫",4*/{0x00,0x00,0x80,0x88,0x88,0x88,0xF8,0x7C,0x44,0x44,0x40,0x40,0x00,0x00,0x00,},{0x00,0x20,0x20,0x30,0x1C,0x0F,0x03,0x07,0x0E,0x18,0x30,0x30,0x20,0x20,0x00,},/*"天",5*/{0x00,0x80,0xF0,0x70,0x64,0x64,0xFC,0xFC,0xD6,0xD2,0x10,0x30,0x30,0x00,0x00,},{0x00,0x00,0x00,0x44,0x55,0x55,0x55,0x5F,0x6A,0x3E,0x1E,0x00,0x00,0x00,0x00,},/*"雪",6*/{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},{0x00,0x00,0x68,0x78,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",7*/{0x00,0x00,0x10,0xB0,0xB0,0x00,0xE0,0xF8,0xDE,0xD6,0x10,0x10,0x00,0x00,0x00,},{0x00,0x08,0x0C,0x0F,0x23,0x3B,0x1B,0x42,0x7F,0x7F,0x09,0x39,0x31,0x00,0x00,},/*"冻",8*/{0x00,0x00,0x00,0xC8,0xE8,0xA8,0x88,0xFC,0xF4,0x84,0xC4,0x40,0x00,0x00,0x00,},{0x00,0x20,0x31,0x1B,0x0E,0x07,0x01,0x1F,0x3F,0x31,0x20,0x30,0x3C,0x1C,0x00,},/*"死",9*/{0x00,0x00,0x08,0x08,0x0E,0xCE,0xE8,0x68,0xCE,0x8E,0x0E,0x04,0x00,0x00,0x00,},{0x08,0x08,0x0C,0x06,0x3F,0x7F,0x42,0x5E,0x5E,0x43,0x73,0x73,0x02,0x02,0x02,},/*"苍",10*/{0x00,0xC0,0xC0,0xFC,0xFC,0xE0,0xF8,0xB8,0xE8,0xF8,0xDC,0xCC,0x80,0x00,0x00,},{0x00,0x10,0x19,0x0F,0x07,0x07,0x07,0x0F,0x1F,0x3F,0x27,0x27,0x30,0x30,0x00,},/*"蝇",11*/{0x00,0x00,0x00,0x00,0x80,0x90,0xFE,0xFE,0x90,0xD0,0x40,0x00,0x00,0x00,0x00,},{0x00,0x20,0x31,0x19,0x0D,0x07,0xFF,0xFF,0x06,0x0C,0x18,0x10,0x30,0x20,0x00,},/*"未",12*/{0x00,0x00,0x00,0x80,0xB8,0x78,0xE8,0xEC,0x3C,0x3C,0x00,0x00,0x00,0x00,0x00,},{0x20,0x30,0x1C,0x0F,0x07,0x04,0x0F,0x0F,0x19,0x31,0x30,0x20,0x20,0x20,0x20,},/*"足",13*/{0x00,0x80,0x80,0x80,0xC8,0xE8,0xB8,0x9E,0xFE,0xEC,0xC4,0x40,0x40,0x40,0x00,},{0x00,0x00,0x00,0x00,0x0E,0x0E,0x0E,0x06,0xC2,0xFF,0x3F,0x00,0x00,0x00,0x00,},/*"奇",14*/{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},{0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,},/*"。