欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
LCD1602的單片機初始化程序
[打印本頁]
作者:
LPFFFFF
時間:
2018-7-28 17:10
標題:
LCD1602的單片機初始化程序
LCD1602的讀、寫操作的程序,及顯示字符串的程序
uchar BusyTest(void) //lcd忙碌狀態檢測
{
bit result;
RS=0;
RW=1;
E=1;
_nop_();
_nop_();
_nop_();
_nop_(); //空操作四個機器周期,給硬件反應時間
result=BF;
E=0;
return result;
}
void WriteInstruction (uchar dictate) //設置模式或地址
{
while(BusyTest()==1);
RS=0; //根據規定,RS和R/W同時為低電平時,可以寫入指令
RW=0;
E=0;
_nop_();
_nop_();
P0=dictate; //將數據送入P0口,即寫入指令或地址
_nop_();
_nop_();
_nop_();
_nop_();
E=1; //E置高電平
_nop_();
_nop_();
_nop_();
_nop_();
E=0; //當E由高電平跳變成低電平時,液晶模塊開始執行命令
}
void WriteAddress(uchar x) //設置實際顯示的地址
{
WriteInstruction(x|0x80);
}
void WriteData(uchar y) //向LCD寫數據
{
while(BusyTest()==1);
RS=1;
RW=0;
E=0;
P0=y;
_nop_();
_nop_();
_nop_();
_nop_();
E=1;
_nop_();
_nop_();
_nop_();
_nop_();
E=0;
}
void LcdInitiate(void) //初始化操作
{
delay(15); //首次寫指令時應給LCD一段較長的反應時間
WriteInstruction(0x38); //顯示模式設置:16×2顯示,5×7點陣,8位數據接口
delay(5);
WriteInstruction(0x38);
delay(5);
WriteInstruction(0x38);
delay(5);
WriteInstruction(0x0f); //顯示模式設置:顯示開,有光標,光標閃爍
delay(5);
WriteInstruction(0x06); //顯示模式設置:光標右移,字符不移
delay(5);
WriteInstruction(0x01); //清屏幕指令,將以前的顯示內容清除
delay(5);
}
void display(uchar hang,uchar lie,uchar *p)
{
uchar a;
if(hang == 1)
{
a = 0x80;
}
if(hang == 2)
{
a = 0xc0;
}
a = a + lie - 1;
while(1)
{
BusyTest();
WriteInstruction(a);
BusyTest();
WriteData(*p);
delay(10);
a++;
p++;
if((*p == '\0')||(a==0x90)||(a==0xd0))
{
break;
}
}
}
復制代碼
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1