实验原理图
实验程序
#include<reg51.h>
#include<stdio.h>
#include<stdlib.h>
#include<intrins.h>
#include<absacc.h>
#define busy 0x80 //用于检测LCD 状态字中的Busy 标识
#define RSaddr 0x1000
#define RWaddr 0x2000
#define CSaddr 0x0400
#define adtn 0xc8ff
#define wc 0xcfff
#define wd 0xdfff
#define rc 0xefff
unsigned char code homepage[] = {"www.ispdown.com"};
unsigned char code email[] = {"ispdown@21cn.com"};
//5ms 延时
void delay5ms(void)
{
unsigned int TempCyc = 5552;
while(TempCyc--);
}
//----------------------------------
//400ms 延时
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[CSaddr+RWaddr+adtn];
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[CSaddr+adtn]=c;
XBYTE[wc]=c;
}
//--------------------------------
void WD_Lcd(char c)
{
waitLcd();
//XBYTE[CSaddr+RSaddr+adtn]=c;
XBYTE[wd]=c;
}
//----------------------------------
void LcdInit()
{
delay5ms();