// void Delay1ms(unsigned int c) //?? 0us
// {
// // unsigned char a, b;
// //
// // for (;c>0;c--)
// // {
// // for (b=38;b>0;b--)
// // {
// // for (a=13;a>0;a--);
// // }
// //
// // }
// }
/*****write command to lcd "com" is data to mcu by use P0.0 to P0.7 pin**********/
void sendcomandtolcd(unsigned char com)
{
rs=0; //fix format of send commond to lcd
P0=com; //transfer data of com to P0 (total 8 pin ).
DelayNms(1);
lcde=1; //enable signal to lcd .
DelayNms(1); //5ms time to let mcu read data from P0.0 to P0.7(com)
lcde=0; //end of enable signal :data transfer finish .
}
void senddatatolcd(unsigned char dat)
{
rs=1; //fix format of send commond to lcd
P0=dat; //transfer data of com to P0 (total 8 pin ).
DelayNms(1);
lcde=1; //enable signal to lcd .
DelayNms(1); //5ms time to let mcu read data from P0.0 to P0.7(com)
lcde=0; //end of enable signal :data transfer finish .
}
/************write normal word to screen*****************************************/
void lcdputstr(unsigned char *d)//lcd display a sentense of "d" ,d<16bit
{
while(*d>0)
{
senddatatolcd(*d++);
}
}
/*************lcd init commond will clear screen and set cursor to beganing of first line ****/
void lcd_init()
{
lcde=0; //Initliz the lcd enable signal to 0
sendcomandtolcd(0x01); //lcd clear screen
sendcomandtolcd(0x38); //fix format of lcd ,0x38 means select lcd screen 16*2 type .
sendcomandtolcd(0x0c); //0x0f =0b 0001 1111 ,last 111 means on display ,on cursor,and cursor blinking.
sendcomandtolcd(0x06); //0b 0000 0110, 11 1,means cursor move righ when receive 1 charactor .1,means:screen not move .