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

📄 gxm1602c.h

📁 LCD1602驱动程序采用c语言驱动lcd1602 ,它是2行16列字符型LCD.
💻 H
字号:
#include <intrins.h>
#define DATA_BUS P2
sbit RS=P3^3;
sbit RW=P3^4;
sbit E=P3^5;
sbit busy=P2^7;
void chk_busy();
void wr_zb(unsigned char,unsigned char);
void send_d(unsigned char dat)
{
 chk_busy();
 RS=1;
 RW=0;
 DATA_BUS=dat;
 E=1;
 _nop_();
 _nop_();
 E=0;
}

void send_i(unsigned char instruction)
{
 chk_busy();
 RS=0;
 RW=0;
 DATA_BUS=instruction;
 E=1;
 _nop_();
 _nop_();
 E=0;
}

void chk_busy(void)
{
 DATA_BUS=0xff;
 RS=0;
 RW=1;
 E=1;
 while(busy);
 E=0;
}

unsigned char read_d(void)
{
  unsigned char dat;
  chk_busy();
  RS=1;
  RW=1;
  E=1;
  _nop_();
  dat=DATA_BUS;
  E=0;
  return dat;
}

void cls()
{
 send_i(0x01);
}

void disp_on()
{
 send_i(0x0c);
}

void disp_off()
{
 send_i(0x8);
}

void set_addr(unsigned char addr)  //第一行0~15  第二行40~45
{
 send_i(0x80|addr);
}

void cursor_on(void)
{
 send_i(0x0e);
}

void cursor_off(void)
{
 send_i(0x0c);
}

void reserve_disp_on(void)
{
 send_i(0xf);
}

void reserve_disp_off(void)
{
 send_i(0xc);
}

void set_cgram_addr(unsigned char addr)
{
  addr&=0x3f;
  addr|=0x40;
  send_i(addr);
}

void initial(void)
{
 cls();
 send_i(0x38);
 send_i(0x06);  //指定光标移动方向
 disp_on();
}

⌨️ 快捷键说明

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