4
uchar code Display[32]="0123456789abcdef 123456789abcdef";
//字符要用双引号括起来,空格也算一个字符,共 32 个字符(0~31)。
void main()
{
Initiallize_LCD();
ShowString(0,0,Display); //从第一个符开始显示
ShowString(0,1,Display+16); //第二行从第 17 个字符写起,0 是第一个字符
while(1);
}
2.2 LCD1602.C 文件
#include<reg51.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
void DelayMS(uint ms) //延时
{
uchar i;
while(ms--)
{
for(i=0;i<120;i++);
}
}
uchar Busy_Check() //忙检查。控制器每次进行读写操作之前,都必须进行读写检测,
//确保 STA7 为 0。
{
uchar LCD_Status; //根据芯片操作时序,读操作时 RS=0,RW=1,EN 高脉冲(150ns)
RS=0; //RS=0 选择命令,=1 选择数据
RW=1; //RW=1 选择读,=0 选择写
EN=1; //开始读
DelayMS(1);
LCD_Status=P0; //读出 STA7 的状态,也就是 P0 的最高位
EN=0;
return LCD_Status; //返回状态值
评论0
最新资源