我不知道你用的是哪一种12864,我用的是没有CS1和CS2的
#include
#include
#define uint unsigned int
#define uchar unsigned char
#define comm 0
#define dat 1
sbit RS = P3^0; //H=data; L="command";
sbit RW = P3^1; //H=read; L="write";
sbit E = P3^2; //input enable;
sbit PSB= P3^3; //H=并口; L="串口";
sbit RST= P3^5; //Reset Signal 低电平有效
sbit busy=P0^7; //lcd busy bit
void wr_lcd (uchar dat_comm,uchar content);
void chk_busy (void);
uchar code tab[]={
"需要显示的字"
};
void init_lcd (void)
{
RST = 1;
PSB = 1;
wr_lcd(comm,0x30); /*30---基本指令动作*/
wr_lcd(comm,0x01); /*清屏,地址指针指向00H*/
wr_lcd(comm,0x06); /*光标的移动方向*/
wr_lcd(comm,0x0c); /*开显示,关游标*/
}
void clrram(void)
{
wr_lcd(comm,0x30);
wr_lcd(comm,0x01);
}
void wr_lcd(uchar dat_comm,uchar content)
{
chk_busy ();
if(dat_comm)
{
RS = 1; //data
RW = 0; //write
}
else
{
RS = 0; //command
RW = 0; //write
}
P0=content; //output data or comm
E = 1;
;
E = 0;
}
void chk_busy(void)
{
P0 = 0xff;
RS = 0;
RW = 1;
E = 1;
while(busy==1);
E = 0;
}
void main()
{
int i;
SP=0x5f;
init_lcd();
wr_lcd(comm,0x30);
wr_lcd(comm,0x80);
for(i=0;i<6;i++)
{
wr_lcd(dat,tab[i]);
}
while(1);
}
Proteus仿真论坛 上面有很多实例