⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1602 dirver.c

📁 调试成功的1602驱动程序
💻 C
字号:
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code tab1[16]={"design by P"};
sbit RS=P3^4;
sbit RW=P3^3;
sbit EN=P3^2;
 void delayms(int n)
  {
   int i;
   while(n--)
   {
   	for(i=0;i<=250;i++)
	{
	_nop_();
	_nop_();
	_nop_();
	_nop_();
	}
   }
  }


 bit busycheck()
{                         
	bit busy;
	RS=0;
	RW=1;
	EN=1;
	_nop_();
	_nop_();
	_nop_();
	_nop_();
     EN=0;
	return busy;
	}

 writecom(uchar zhi)
{
    while(busycheck());
    RS=0;
    RW=0;
    EN=0;
 	_nop_();
    _nop_();
    P0=zhi;
    _nop_();
	_nop_();
	_nop_();
	_nop_();
	EN=1;	
	_nop_();
	_nop_();
	_nop_();
	_nop_();
	EN=0;	 
 }

 writedata(uchar shu)
 {
    while(busycheck());
    RS=1;
	RW=0;
	EN=0;
	_nop_();
	_nop_();
	P0=shu;
	_nop_();
	_nop_();
	_nop_();
	_nop_();
	EN=1;
	_nop_();
	_nop_();
	_nop_();
	_nop_();
	EN=0;
 }

  lcdinit()
   {
	 writecom(0x38);
	 delayms(1);
	 writecom(0x0c);
	 delayms(1); 
	 writecom(0x06);
	 delayms(1);
     writecom(0x01); 
	 delayms(1); 
   }

main()
{
 uchar i;
 lcdinit();
 delayms(1);
 writecom(0x80|0x00);
 delayms(1);
 writecom(0x38);
 while(i!=0x010)
   {
     writedata(tab1[i]);
     i++;
     }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -