完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
`源程序如下,DH11按资料提供的参照图接线。数据传输口为P2.2, 注释乱码了,请大神看附件 //ÒÑÓö˿ڣºP2.5,P2.6,P2.7,P3.2,P3.4,P0 #include #include /**********LCD_12864***************************/ #define uchar unsigned char #define unint unsigned int #define LCD_DATA P0 ***it LCD_RS=P2^6; ***it LCD_RW=P2^5; ***it LCD_EN=P2^7; ***it LCD_PSB=P3^2; ***it LCD_RES=P3^4; /***********ÑÓʱxms************* void delay_xms(uint a) { uint i,j; for(i=a;i>0;i--) for(j=110;j>0;j--); } ******************************/ //******************************* /**************ÑÓʱ1ms***********/ void delay1ms() { unsigned char i,j; for(i=0;i<4;i++) for(j=0;j<33;j++);//(3j+2)*i=(3¡Á33+2)¡Á10=1010(΢Ãë)£¬¿ÉÒÔÈÏΪÊÇ1ºÁÃë } /***********ÑÓʱxms**************************/ void delay_xms(uchar n) { unsigned char i; for(i=0;i } /***************************************************** /*********ÅÐæ*****************/ bit check_busy() { bit busy; LCD_RS=0; LCD_RW=1; LCD_EN=1; delay_xms(2); busy=(bit)(LCD_DATA&0X80); LCD_EN=0; return busy; } //µÈ´ýLCD¿ÕÏÐ void wait() { while(check_busy()); } //****************************** /*************дָÁî************/ void write_cmd(uchar cmd) { wait(); LCD_RS=0; LCD_RW=0; LCD_EN=0; delay_xms(2); LCD_DATA=cmd; LCD_EN=1; delay_xms(2); LCD_EN=0; } //******************************* /*************дÊý¾Ý***************/ void write_data(uchar dat) { wait(); LCD_RS=1; LCD_RW=0; LCD_EN=0; delay_xms(5); LCD_EN=1; LCD_DATA=dat; delay_xms(10); LCD_EN=0; } //************************************* /***********LCD_12864³õʼ»¯*************/ void initial_12864() { delay_xms(40); LCD_PSB=1; delay_xms(1); LCD_RES=0; delay_xms(1); LCD_RES=(1); write_cmd(0x30);//»ù±¾Ö¸Áî delay_xms(10); write_cmd(0x0c);//¿ªÏÔʾ£¬¹Ø¹â±ê delay_xms(10); write_cmd(0x01);//ÇåÆÁ delay_xms(10); } //************************************** /***********×Ö·û´®Ð´ÈëµØÖ·**************/ void LCD_POS(uchar X, uchar Y) { uchar pos; if(X==0) {X=0x80;} if(X==1) {X=0x90;} if(X==2) {X=0x88;} if(X==3) {X=0x98;} pos=X+Y; write_cmd(pos); } //***************************************** /***************×Ö·û´®Ð´ÈëÏÔʾ**************/ unsigned char LCD_DISPLAY(uchar x, uchar y, uchar *DATA) { int i=0; LCD_POS(x,y); while(DATA!=' |
