資源描述:
《hd44780源程序》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、/*LCD型號:HD44780???????*//*打印機型號:EPSONM311???*/#include#include#include#define??uchar?????unsignedchar#define??uint??????unsignedint???????????????????????????????????//定義8255I/O端口地址#define??PCC8255???XBYTE[0x007f]???//8255命令口地址#define??PC8255????XBY
2、TE[0x007e]???//8255的PC口地址#define??PB8255????XBYTE[0x007d]???//8255的PC口地址#define??PA8255????XBYTE[0x007c]???//8255的PC口地址sfr??????RPCTL??????=0xD8;sbit?????RPCTL_5????=RPCTL^5;sbit?????LS164A?????=P2^5;sbit?????LS164cp????=P2^6;sbit?????Print_busy=P3^3;sbit?????IC_RST?????=P1^1;sb
3、it?????IC_CLK?????=P1^0;sbit?????IC_IO??????=P1^2;sbit?????IC_PGM?????=P3^2;ucharcodetable1[16]="FEDCBA9870123456";ucharcodetable2[16]="0000123456789ABC";void??INIT_8255(void);????????????/*初始化8255*/void??LcdInit(void);??????????????/*LCD初始化函數(shù)*/void??LcdCmd(uchar);??????????????
4、/*LCD控制命令函數(shù)*/void??LcdData(uchar);?????????????/*LCD數(shù)據(jù)輸入函數(shù)*/void??LcdClr(void);???????????????/*LCD清屏函數(shù)*/void??LcdStr(uchar*);????????????/*顯示字符串函數(shù)*/void??LcdDisp(ucharx,uchard);void??Delay_msec(uintx);?????????/*延時函數(shù)*/ucharGetkey(void);???????????????/*鍵盤函數(shù)*/void??PrintInit(voi
5、d);????????????/*打印初始化函數(shù)*/void??PrintData(uchar??d);???????/*打印函數(shù)*/void??PrintString(uchar*p);??????//打印字符串voidLcdDisp(ucharx,uchard)????//指定位置顯示字符x:LCD位置d:字符{??if(x<9)??{?????LcdCmd(0x80+x);?????LcdData(d);??}??else??{?????LcdCmd(0xc0+x);?????LcdData(d);??}}voidLcdStr(uchar*p)?
6、???????/*顯示字符串函數(shù)*/{???datauchari;???LcdCmd(0x80);?????????????//設(shè)置顯示數(shù)據(jù)RAM???for(i=0;i<=7;i++)???{????????LcdData(*p);?????????/*charofLCM*/????????p++;???}??????LcdCmd(0xc0);?????????????//設(shè)置顯示數(shù)據(jù)RAM???for(i=0;i<=7;i++)???{????????LcdData(*p);????????/*charofLCM*/????????p++;???}
7、}void??LcdClr()???????????????/*LCD清屏函數(shù)-----通過送0x20清屏*/{???datauchari;???LcdCmd(0x80);?????????????//設(shè)置顯示數(shù)據(jù)RAM???for(i=0;i<=7;i++)????????LcdData(0x20);????????/*charofLCM*/???LcdCmd(0xc0);?????????????//設(shè)置顯示數(shù)據(jù)RAM???for(i=0;i<=7;i++)????????LcdData(0x20);?????????/*charofLCM*/}
8、voidLcdClr1(void)???????????/*LCD清屏函數(shù)-----通過控制