1)电路原理图
2)源程序
#include
#include
#include
#include
#include
#define busy 0x80 file://用于检测LCD状态字中的Busy标识
#define RSaddr 0x1000
#define RWaddr 0x2000
#define CSaddr 0x0400
#define wc 0xcfff
#define wd 0xdfff
#define rc 0xefff
unsigned char code homepage[] = {"www.ispdown.com"};
unsigned char code email[] = {"ispdown@21cn.com"};
void delay5ms(void)
{
unsigned int TempCyc = 5552;
while(TempCyc--);
}
void delay400ms(void)
{
unsigned char TempCycA = 5;
unsigned int TempCycB;
while(TempCycA--)
{
TempCycB=7269;
while(TempCycB--);
};
}
void waitLcd()
{
char temp;
bit flag=1;
while(flag==1)
{
temp=XBYTE[rc];
if (temp>>7==0) flag=0;
P1=temp;
}
P1=0xff;
}
void WC_Lcd(bit isCheck,char c)
{
if (isCheck==1) waitLcd();
XBYTE[wc]=c;
}
void WD_Lcd(char c)
{
waitLcd();
XBYTE[wd]=c;
}
void LcdInit()
{
delay5ms();
delay5ms();
delay5ms();
WC_Lcd(0,0x38);
delay5ms();
WC_Lcd(0,0x38);
delay5ms();
WC_Lcd(0,0x38);
delay5ms();
WC_Lcd(1,0x38);
WC_Lcd(1,0x08);
WC_Lcd(1,0x01);
WC_Lcd(1,0x06); // 显示光标移动设置
WC_Lcd(1,0x
}
void displayOneChar(unsigned char X, unsigned char Y, unsigned char DData)
{
Y &= 0x1;
X &= 0xF;
if (Y) X = 0x40;
X = 0x80;
WC_Lcd(0,X);
WD_Lcd(DData);
}
void displayListChar(unsigned char X, unsigned char Y, unsigned char code *DData)
{
unsigned char ListLength;
ListLength = 0;
Y &= 0x1;
X &= 0xF;
while (DData[ListLength]>0x20)
{
if (X <= 0xF)
{
displayOneChar(X, Y, DData[ListLength]);
ListLength++;
X++;
}
}
}
void main(void)
{
delay400ms();
LcdInit();
displayListChar(0, 0, homepage);
displayListChar(0, 1, email);
while(1);
}
3)效果图
上一篇:Keil C51编译错误总结
下一篇:关于在KEIL C51 中嵌入汇编以及C51与A51间的相互调用
推荐阅读最新更新时间:2024-03-16 13:52