本文引用地址:http://m.butianyuan.cn/article/201611/321023.htmvoid wait_LCD_Ready(void)
{
uchar temp1;
LCD_DATA_PORT=0XFF;
LCD_DATA_PIN; //D7設(shè)為輸入,準(zhǔn)備判斷LCD忙標(biāo)志
//1為忙 0為空閑
LCD_RS_0;
LCD_RW_1; //讀
LCD_EN_1;
nus_delay(2);
while((temp1=PORTD & 0X80));
LCD_EN_0;
LCD_RS_1;
LCD_DATA_POUT;
}
void LCD_write_onechar(uchar COMM,uchar DAT)
{
wait_LCD_Ready(); //等待LCD空閑
LCD_RW_0; //寫
//寫數(shù)據(jù)
if(COMM==0)
{
LCD_RS_1; //RS高電平向LCD寫數(shù)據(jù)
LCD_DATA_PORT=DAT;
}
//寫命令
else
{
LCD_RS_0;
LCD_DATA_PORT=COMM;
}
LCD_en_write();
nus_delay(2);
LCD_RW_1;
LCD_RS_1;
}
void LCD_write_string(uchar X,uchar Y,uchar *string)
{
set_LCD_xy( X, Y ); //設(shè)置LCD顯示坐標(biāo)
while (*string)
{
LCD_write_onechar(0,*string );
string ++; //指向下一顯示字符地址
}
}
void set_LCD_xy(uchar x, uchar y )
{
uchar DIS_address;
if (y == 0)
DIS_address = 0x80 + x; //第一行X列
else
DIS_address = 0xc0 + x;
LCD_write_onechar( DIS_address, 0 ); //第二行X列
}
void nus_delay(uint nus)
{
int j=10;
while(nus--)
{
while(j--);
j=10;
}
}
void nms_delay(uint nms)
{
while(nms--)
nus_delay(1000);
}
評論