|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2010-10-20 17:01:32
|
显示全部楼层
//写命令到LCD 上半屏
void write_com(unsigned char cmdcode)
{ RS_0; //RS=0;
RS_0; //RS=0;
E_1; //E =1;
// E2_0; //
P7=cmdcode; //
E_0; //E =0;
//E2_0; //E =0;
delay(5);
}
//写命令到LCD 下半屏
void write2_com(unsigned char cmdcode)
{ RS_0; //RS=0;
E2_1; //E =1;
E_0; //E =1;
P7=cmdcode; //
E_0; //E =0;
//E2_0; //E =0;
delay(5);
}
//写数据到LCD 上半屏
void write_data(unsigned char Dispdata)
{ RS_1; //RS=1;
E_1; //E =1;
E2_0; //E2 =1;
P7=Dispdata; //
E_0; //E =0;
E2_0; //E =0;
delay(5);
}
//写数据到LCD 下半屏
void write2_data(unsigned char Dispdata)
{ RS_1; //RS=1;
E2_1; //E2 =1;
E_0; //E =1;
P7=Dispdata; //
E_0; //E =0;
E2_0; //E =0;
delay(5);
}
//图位清屏
void clear_d()
{ unsigned char x,y;
for ( x=0;x<16;x++)
for (y=0;y<32;y++)
{ write_com(0x34);
write_com(0x80+y);
write_com(0x80+x);
write_com(0x30);
write_data(0x00);
write_data(0x00);
/*for (y=0;y<32;y++)
{ write2_com(0x34);
write2_com(0x80+y);
write2_com(0x80+x);
write2_com(0x30);
write2_data(0x00);
write2_data(0x00);
} */
}
}
//初始化LCD
void lcdinit()
{
//R_W=0;
delay(5000);
write_com(0x30);
delay(20);
write_com(0x30);
delay(20);
write_com(0x0c);
delay(10);
write_com(0x01);
delay(200);
write_com(0x06);
//clear_d();
delay(200);
delay(5000);
write2_com(0x30);
delay(20);
write2_com(0x30);
delay(20);
write2_com(0x0c);
delay(10);
write2_com(0x01);
delay(200);
write2_com(0x06);
delay(200);
// clear_d();
delay(200);
}
好心人看看问题出在哪里 |
|