單片機(jī)LCD1602底層驅(qū)動子程序
/**********************LCD1602底層驅(qū)動程序***************************/
/********************************************************************/
//delay: 延時(shí)xms
void delay(uint xms)
{
uchar i, j;
for(i = 0; i < xms; i++)
for(j = 0; j < 110; j++);
}
//wait: 判忙等待
void wait()
{
P0 = 0xff;
do
{
RS = 0;
RW = 1;
EN = 0;
EN = 1;
}while(BUSY == 1);
EN = 0;
}
//write:cmd 寫入命令
void write_cmd(uchar cmd)
{
RS = 0;
RW = 0;
EN = 0;
P0 = cmd;
EN = 1;
EN = 0;
}
//write:data寫入數(shù)據(jù)
void write_data(uchar datas)
{
RS = 1;
RW = 0;
EN = 0;
P0 = datas;
EN = 1;
EN = 0;
}
//send:string 發(fā)送一串字符
void send_string(uchar* str)
{
while(*str !=