蜜臀av午夜精品福利-日韩精品av在线一区二区-丰满熟女人妻一区二区三区-懂色日韩欧美国产亚洲

新聞詳情

液晶模塊HG128641與8051單片機(jī)應(yīng)用示例-2

日期:2025-04-30 18:58
瀏覽次數(shù):1139
摘要:

液晶模塊HG128641與8051單片機(jī)應(yīng)用示例-2  接上一篇

四‘、液晶模塊HG128641與8051單片機(jī)連接電路圖:
   

五、HG128641與8051單片機(jī)示例程序(寫指令寫數(shù)據(jù)等主要子程序)

/************
  延時(shí)子程序
*****************/
void Delay(uint t)
{uint i,j;
for(i=0;i<t;i++)
for(j=0;j<305;j++)
_nop_();_nop_();_nop_();_nop_();
}
/***********
 忙判斷子程序
************/
void Busy()
{
 A0=0;
 RW=1;
buslcd=0xff;
 E=1;
_nop_();
while(buslcd&0x80);
E=0;
_nop_();
}
/*********************
 寫入左半屏指令 子程序
**********************/
void Writecom1(uchar wcom)
{
CS1=1;CS2=0;
 Busy();
 buslcd=wcom;
 A0=0;
 RW=0;
 E=1;
_nop_();
  E=0;
_nop_();}
/*********************
 寫入左半屏數(shù)據(jù) 子程序
**********************/
void Writedata1(uchar wdata)
{
CS1=1;CS2=0;
 Busy();
 buslcd=wdata;
 A0=1;
 RW=0;
 E=1;
_nop_();
 E=0;
_nop_();}
/*********************
 寫入右半屏指令 子程序
***********************/
void Writecom2(uchar wcom)
{
CS1=0;CS2=1;
 Busy();
 buslcd=wcom;
 A0=0;
 RW=0;
 E=1;
_nop_();
  E=0;
_nop_();}
/************************
 寫入右半屏數(shù)據(jù) 子程序
*************************/
void Writedata2(uchar wdata)
{
CS1=0;CS2=1;
 Busy();
 buslcd=wdata;
 A0=1;
 RW=0;
 E=1;
_nop_();
 E=0;
_nop_();}

/*********************
讀出左半屏數(shù)據(jù) 子程序
**********************/
uchar Readdata1()
{
uchar rdata;
CS1=1;CS2=0;
 Busy();
 A0=1;
 RW=1;
 E=1;
 rdata=buslcd;
_nop_();_nop_();_nop_();
 E=0;
_nop_();
return rdata;
}
/**********************
讀出右半屏數(shù)據(jù) 子程序
****************************/
uchar Readdata2()
{
uchar rdata;
CS1=0;CS2=1;
 Busy();
 A0=1;
 RW=1;
 E=1;
 rdata=buslcd;
_nop_();_nop_();_nop_();
 E=0;
_nop_();
return rdata;
}
/*********************
    清屏子程序
****************************/
void Clear(void)
{uchar i,j;
for(i=0;i<8;i++)
{Writecom1(0xb8+i);Writecom1(0x40);
Writecom2(0xb8+i);;Writecom2(0x40);
for(j=0;j<64;j++)
{Writedata1(0);Writedata2(0);}}
}
/**********************
    液晶初始化子程序
***********************/
void INT()
{
Delay(3);
Writecom1(0x3f);
Writecom2(0x3f);
Writecom1(0xc0);
Writecom2(0xc0);
Writecom1(0xb8);
Writecom2(0xb8);
Writecom1(0x40);
Writecom2(0x40);
Clear();
}