新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > 单片机液晶显示代码

单片机液晶显示代码

作者:时间:2012-06-23来源:网络收藏

本文引用地址:http://www.eepw.com.cn/article/171260.htm

//***************************************以下****************************************************

void waitLcd() //just wait until 液晶不忙为止

{

char temp;

bit flag=1;

while(flag==1)

{

temp=XBYTE[rc];

if (temp>>7==0) flag=0;

P1=temp;

}

P1=0xff;

}

//just wait until 液晶不忙为止

void WriteCommand_Lcd(bit isCheck,char c)

{

if (isCheck==1) waitLcd();

XBYTE[wc]=c;

}

void writedata(char c)

{

waitLcd();

XBYTE[wd]=c;

}

void LcdInit()

{

delay5ms();

delay5ms();

delay5ms();

WriteCommand_Lcd(0,0x38); //三次显示模式设置,不检测忙信号

delay5ms();

WriteCommand_Lcd(0,0x38);

delay5ms();

WriteCommand_Lcd(0,0x38);

delay5ms();

WriteCommand_Lcd(1,0x38); //显示模式设置,开始要求每次检测忙信号,8位2行5*7

WriteCommand_Lcd(1,0x08); //关闭显示

WriteCommand_Lcd(1,0x01); //清显示

WriteCommand_Lcd(1,0x06); // 文字不动,光标右移

WriteCommand_Lcd(1,0x0C); // 显示开及光标设置

}

void displayListChar(unsigned char X, unsigned char Y, uchar DData)

{

Y = 0x1;

X = 0xF;

if (X = 0xF)

{

Y = 0x1;

X = 0xF;

if (Y) X = 0x40;

X = 0x80;

WriteCommand_Lcd(0,X);

writedata(dispbuf[DData]);

}

}

//****************************************以上驱动*****************************************************

//*************************************************

//**********************************以下显示时间*****************************************************

void Show_Time(void)

{

displayListChar(0,0,hour/10);

displayListChar(1,0,hour%10);

displayListChar(2,0,10);

displayListChar(3,0,minute/10);

displayListChar(4,0,minute%10);

displayListChar(5,0,10);

displayListChar(6,0,second/10);

displayListChar(7,0,second%10);

}

//**********************************以上显示时间*****************************************************



评论


相关推荐

技术专区

关闭