欢迎来到天天文库
浏览记录
ID:9000779
大小:863.55 KB
页数:53页
时间:2018-04-14
《单片机课设(三篇课设均带带仿真图和源程序代码)》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、12232LCDPROTEUS仿真(51C)12232在proteus里模型用关键字P,“12232” 查不出LCD的,要用1232查找 。好不容易得到模型,编写程序,一直不能成功。第一个字符正常,后面的就乱了。最后才明白:12232的模型和实物不一样,共4页(这和实物一样),每页只能从地址0开始,水平方向从左往右显示。另外,按实物的程序,仿真中显示是相反的,所以初始化时应改为反向显示,仿真显示才正常。//12232LCDproteus仿真//20120120E:DPJ_C1223212232UV412232_2C.C#include2、h>#include#include"chr16.h"#defineucharunsignedchar#defineuintunsignedint#defineLCD_DBP0sbitE2=P3^5;sbitE1=P3^6;sbitA0=P3^7;voidWR_Mcom(uchari){E1=1;_nop_();_nop_();<30/53>A0=0;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E1=0;_nop_();_nop_();}voidWR_Mdat(uchari){E1=1;_nop_3、();_nop_();A0=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E1=0;_nop_();_nop_();}voidWR_Scom(uchari){A0=0;_nop_();_nop_();E2=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E2=0;_nop_();_nop_();<30/53>}voidWR_Sdat(uchari){A0=1;_nop_();_nop_();E2=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_()4、;E2=0;_nop_();_nop_();}voidlcdini(){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_Sc5、om(0XC0);WR_Mcom(0XAF);WR_Scom(0XAF);//显示开关:开}voidSetPage(ucharpage0,ucharpage1){WR_Mcom(0xB86、page1);<30/53>WR_Scom(0xB87、page0);}voidSetAddress(ucharaddress0,ucharaddress1){WR_Mcom(address1&0x7F);WR_Scom(address0&0x7F);}voidclrscr(){uchari;ucharpage;for(page=0;page<4;page++){SetPa8、ge(page,page);SetAddress(0,0);for(i=0;i<61;i++){WR_Mdat(0);WR_Sdat(0);}}}voiddisplay(){uchari,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]);}else<30/9、53>{WR_Mdat(chr16[2*i+16][j+(page-2)*15]);WR_Sdat(chr16[2*i+24][j+(page-2)*15]);}}}}}voidmain(){lcdini();clrscr();while(1){display();}}/****************************************************************************************/CHR16.H//unsignedcharcodechr16[32][15]={{0x00,0x40,0x40,10、0xDA,0xFE,0x24,0x20,0xF8,0xDE,0xD
2、h>#include#include"chr16.h"#defineucharunsignedchar#defineuintunsignedint#defineLCD_DBP0sbitE2=P3^5;sbitE1=P3^6;sbitA0=P3^7;voidWR_Mcom(uchari){E1=1;_nop_();_nop_();<30/53>A0=0;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E1=0;_nop_();_nop_();}voidWR_Mdat(uchari){E1=1;_nop_
3、();_nop_();A0=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E1=0;_nop_();_nop_();}voidWR_Scom(uchari){A0=0;_nop_();_nop_();E2=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_();E2=0;_nop_();_nop_();<30/53>}voidWR_Sdat(uchari){A0=1;_nop_();_nop_();E2=1;_nop_();_nop_();LCD_DB=i;_nop_();_nop_()
4、;E2=0;_nop_();_nop_();}voidlcdini(){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_Sc
5、om(0XC0);WR_Mcom(0XAF);WR_Scom(0XAF);//显示开关:开}voidSetPage(ucharpage0,ucharpage1){WR_Mcom(0xB8
6、page1);<30/53>WR_Scom(0xB8
7、page0);}voidSetAddress(ucharaddress0,ucharaddress1){WR_Mcom(address1&0x7F);WR_Scom(address0&0x7F);}voidclrscr(){uchari;ucharpage;for(page=0;page<4;page++){SetPa
8、ge(page,page);SetAddress(0,0);for(i=0;i<61;i++){WR_Mdat(0);WR_Sdat(0);}}}voiddisplay(){uchari,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]);}else<30/
9、53>{WR_Mdat(chr16[2*i+16][j+(page-2)*15]);WR_Sdat(chr16[2*i+24][j+(page-2)*15]);}}}}}voidmain(){lcdini();clrscr();while(1){display();}}/****************************************************************************************/CHR16.H//unsignedcharcodechr16[32][15]={{0x00,0x40,0x40,
10、0xDA,0xFE,0x24,0x20,0xF8,0xDE,0xD
此文档下载收益归作者所有