单片机LCD1602底层驱动子程序
/**********************LCD1602底层驱动程序***************************/
/********************************************************************/
//delay: 延时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写入数据
void write_data(uchar datas)
{
RS = 1;
RW = 0;
EN = 0;
P0 = datas;
EN = 1;
EN = 0;
}
//send:string 发送一串字符
void send_string(uchar* str)
{
while(*str != )
{
write_data(*str++);
}
}
//lcd1602:init LCD1602 显示初始化
void lcd_init()
{
delay(15);
write_cmd(0x38);
delay(5);
write_cmd(0x38);
delay(5);
write_cmd(0x38);
wait();
write_cmd(0x38); //设置16 * 2,5 * 7点阵
wait();
write_cmd(0x08);
wait();
write_cmd(0x01);//清屏
wait();
write_cmd(0x06);
wait();
write_cmd(0x0c); //开显示
}
单片机LCD1602底层驱 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)