a一级爱做片免费观看欧美,久久国产一区二区,日本一二三区免费,久草视频手机在线观看

新聞中心

EEPW首頁 > 光電顯示 > 設計應用 > 液晶顯示源程序代碼

液晶顯示源程序代碼

作者: 時間:2011-05-18 來源:網絡 收藏

**************************************************
*yj.c
*連線圖:
* DB0---DPROT.0 DB4---DPROT.4 RS-------------P2.5
* DB1---DPROT.1 DB5---DPROT.5 RW-------------P2.6
* DB2---DPROT.2 DB6---DPROT.6 E--------------P2.7
* DB3---DPROT.3 DB7---DPROT.7 VLCD接10K可調電阻到GND*
*80C51的晶振頻率為12MHz
*程序
***************************************************/
#include reg51.h
#include
#include
#define DPORT P0
#define uchar unsigned char
sbit RS = P2^5;
sbit RW = P2^6;
sbit E = P2^7;

uchar Xpos; //列方向地址指針
uchar Ypos; //行方向地址指針


#define NoDisp 0
#define NoCur 1
#define CurNoFlash 2
#define CurFlash 3
/*延時程序
由Delay參數確定延遲時間
*/

void LcdWcn(uchar);
void LcdWc(uchar);
void WriteChar(uchar);
void LcdPos();
void LcdWd(uchar);
void LcdWdn(uchar);


void mDelay(unsigned int Delay)
{ unsigned int i;
for(;Delay>0;Delay--)
{ for(i=0;i124;i++)
{;}
}
}

/*光標設置命令
Cur 為設定光標參數
*/
void SetCur(uchar Cur)
{ switch(Cur)
{ case 0x0:
{ LcdWc(0x08); //關顯示
break;
}
case 0x1:
{ LcdWc(0x0c); //開顯示但無光標
break;
}
case 0x2:
{ LcdWc(0x0e); //開顯示有光標但不閃爍
break;
}
case 0x3:
{ LcdWc(0x0f); //開顯示有光標且閃爍
break;
}
default: break;
}
}
/*清屏命令
*/
void ClrLcd()
{ LcdWc(0x01);
}
/*在指定的行與列顯示
*/
void WriteChar(uchar c)
{ LcdPos();
LcdWd(c);
}
/*正常讀寫操作之前檢測LCD控制器
*/
void WaitIdle()
{ uchar tmp;
DPORT=0xff;
RS=0;
RW=1;
E=1;
_nop_();
for(;;)
{ tmp=DPORT;
tmp=0x80;
if(tmp==0)
break;
}
E=0;
}

/*不檢測忙的寫字符子程序
*/
void LcdWdn(uchar c)
{
RS=1;
RW=0;
DPORT=c; //寫入待寫字符
E=1;
_nop_();


上一頁 1 2 下一頁

評論


相關推薦

技術專區

關閉