新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51+12864液晶調(diào)試成功

51+12864液晶調(diào)試成功

作者: 時間:2016-11-25 來源:網(wǎng)絡(luò) 收藏


#include
#define uchar unsigned char
#define uint unsigned int
#define LCDLCDDisp_off 0x3e
#define LCDLCDDisp_on 0x3f
#define Page_Add 0xb8
#define LCDCol_Add 0x40
#define Start_Line 0xC0

#define data_ora P0
sbit LCDMcs=P2^1;//H-選擇右半屏信號
sbit LCDScs=P2^2; //H-選擇左半屏信號
sbit RESET=P2^3;//低電平復(fù)位
sbit LCDDi=P2^4;
sbit LCDRW=P2^5;
sbit LCDEnable=P2^6;
uchar code Hz_xu[]=
{
0x02,0xF2,0x12,0x12,0x1E,0x00,0x80,0x80,0xFF,0xA0,0x90,0x88,0x86,0x84,0x80,0x00,
0x01,0x03,0x41,0x81,0x7F,0x00,0x00,0x40,0xFF,0x40,0x23,0x0C,0x10,0x60,0x20,0x00
};
uchar code jia[]=
{
0x00,0x02,0x02,0xE2,0xAA,0xAA,0xAA,0xAF,0xAA,0xAA,0xAA,0xE2,0x02,0x02,0x00,0x00,
0x82,0x4A,0x2A,0x1E,0x4B,0x8A,0x7A,0x02,0x02,0x7B,0x4A,0x4A,0x7A,0x02,0x02,0x00
};
uchar code de[]=
{
0x10,0x88,0xE4,0x3B,0x12,0x04,0xF4,0x94,0xF4,0x9F,0x94,0xF4,0x94,0xF4,0x04,0x00,
0x01,0x00,0xFF,0x00,0x42,0x3A,0x02,0x3A,0x42,0x4A,0x52,0x42,0x62,0x0A,0x32,0x00
};

本文引用地址:http://butianyuan.cn/article/201611/321331.htm


void LCDdelay(uint t)
{ uint i,j;
for(i=0;i for(j=0;j<10;j++)
;
}

void CheckState()
{
uchar dat,DATA;
LCDDi=0;//Di=0,表示DB7-DB0為顯示指令數(shù)據(jù)
LCDRW=1;//RW=1,表示數(shù)據(jù)被讀到DB7-DB0
do
{
DATA=0x00;
LCDEnable=1;
LCDdelay(2);
dat=DATA;
LCDEnable=0;
dat=0x80&dat;//僅當(dāng)?shù)谄呶粸?時菜可操作(判斷BUSY信號)
}
while(!(dat==0x00));
}
void write_com(uchar cmdcode)
{
CheckState(); //檢查是否忙
LCDDi=0;
LCDRW=0;
P0=cmdcode;
LCDdelay(2);
LCDEnable=1;
LCDdelay(2);
LCDEnable=0;
}
void inti_lcd()
{
LCDdelay(100);
LCDMcs=1; //關(guān)閉兩屏
LCDScs=1;
LCDdelay(100);
write_com(LCDLCDDisp_off); //關(guān)屏
write_com(Page_Add+0); //設(shè)置頁地址
write_com(Start_Line+0);//設(shè)置起始行
write_com(LCDCol_Add+0); //設(shè)置起始列
write_com(LCDLCDDisp_on); //開屏
}
void write_data(uchar LCDDispdata)
{
CheckState(); //檢查是否忙
LCDDi=1;
LCDRW=0;
P0=LCDDispdata;
LCDdelay(2);
LCDEnable=1;
LCDdelay(2);
LCDEnable=0;
}
void Clr_Scr() //清楚LCD內(nèi)存程序{
{
uchar j,k;
LCDMcs=0; //打開兩屏
LCDScs=0;
write_com(Page_Add+0);
write_com(LCDCol_Add+0);
for(k=0;k<8;k++)
{write_com(Page_Add+k);
for(j=0;j<64;j++)
{
write_com(LCDCol_Add+j);
write_data(0x00);//控制列數(shù)0-63,共64列,列表地址自動加1
}
}
}

void hz_LCDDisp16(uchar page,uchar column,uchar code*hzk)
{
uchar j=0,i=0;
for(j=0;j<2;j++)
{
write_com(Page_Add+page+j);
write_com(LCDCol_Add+column);
for(i=0;i<16;i++)
write_data(hzk[16*j+i]);
}
}
void main()
{
inti_lcd();
while(1)
{
Clr_Scr();
// LCDdelay(500);
LCDMcs=1;
LCDScs=0; //左屏開顯示
hz_LCDDisp16(0,32,Hz_xu);//為某個漢字的首地址
LCDMcs=0;//右屏開顯示
LCDScs=1;
hz_LCDDisp16(2,0,jia);
hz_LCDDisp16(2,16,de);
LCDdelay(500);
}
}



關(guān)鍵詞: 5112864液晶調(diào)試成

評論


技術(shù)專區(qū)

關(guān)閉