如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
/*****************************************************************//**//*名称:12864液晶移动显示*//*功能:12864液晶移动显示*//*E-mail:hbyuan2007@sina.com*//*编写日期:2009.07*//*****************************************************************/#include<reg51.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintsbitLCD_RS=P2^0;sbitLCD_RW=P2^1;sbitLCD_EN=P2^2;ucharcodedis1[]={"ILOVE8051MCU"};ucharcodedis2[]={"TEL:13808311069"};/*******************************************************************//*/*延时子程序/*/*******************************************************************/voiddelay(intms){inti;while(ms--){for(i=0;i<250;i++){_nop_();_nop_();_nop_();_nop_();}}}/*******************************************************************//*/*检查LCD忙状态/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。/*/*******************************************************************/bitlcd_busy(){bitresult;LCD_RS=0;LCD_RW=1;LCD_EN=1;_nop_();_nop_();_nop_();_nop_();result=(bit)(P0&0x80);LCD_EN=0;returnresult;}/*******************************************************************//*/*写指令数据到LCD/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。/*/*******************************************************************/voidlcd_wcmd(ucharcmd){while(lcd_busy());LCD_RS=0;LCD_RW=0;LCD_EN=0;_nop_();_nop_();P0=cmd;_nop_();_nop_();_nop_();_nop_();LCD_EN=1;_nop_();_nop_();_nop_();_nop_();LCD_EN=0;}/*******************************************************************//*/*写显示数据到LCD/*RS=H,RW=L,E=高脉冲,D0-D7=数据。/*/*******************************************************************/voidlcd_wdat(uchardat){while(lcd_busy());LCD_RS=1;LCD_RW=0;LCD_EN=0;P0=dat;_nop_();_nop_();_nop_();_nop_();LCD_EN=1;_nop_();_nop_();_nop_();_nop_();LCD_EN=0;}/*******************************************************************//*/*设定显示位置/*/*******************************************************************/voidlcd_pos(ucharpos){lcd_wcmd(pos|0x80);//数据指针=8