#include
sbit LCDE=P2^7;
sbit RW=P2^5;
sbit RS=P2^6;
unsigned char wenzi[]="hahahaa";
void WriteCom(unsigned char com);
void WriteDate(unsigned char dat);
void Init();
void Delay1ms();
void main()
{
unsigned char i;
Init();
for(i=0;i<7;i++)
WriteDate(wenzi[i]);
while(1)
{
}
}
void Init()
{
WriteCom(0x38);
WriteCom(0x0c);
WriteCom(0x06);
WriteCom(0x01);
WriteCom(0x80);
}
void WriteCom(unsigned char com) //写入命令
{
RS=0;
RW=0;
P0=com;
Delay1ms();
LCDE=1;
Delay1ms();
LCDE=0;
}
void WriteData(unsigned char dat) //写入数据
{
RS=1;
RW=0;
P0=dat;
Delay1ms();
LCDE=1;
Delay1ms();
LCDE=0;
}
void Delay1ms()
{
unsigned char a,b,c;
for(c=1;c>0;c--)
for(b=38;b>0;b--)
for(a=130;a>0;a--);
}
Build target 'Target 1'
compiling LCD1602.c...
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_WRITEDATA?LCD1602
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: _WRITEDATE
MODULE: LCD1602.obj (LCD1602)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: _WRITEDATE
MODULE: LCD1602.obj (LCD1602)
ADDRESS: 089AH
Program Size: data=18.0 xdata=0 code=253
creating hex file from "LCD1602"...
"LCD1602" - 0 Error(s), 3 Warning(s).