#ifndef _LCD1602_H_
#define _LCD1602_H_
#include "reg51.h"
#include "intrins.h"
#define NOP _nop_()
#define GPIO_LCD P1
#define WAIT() NOP,NOP,NOP,NOP;
#define LCD_WRITE 0
#define LCD_READ 1
#define LCD_DAT 1
#define LCD_CMD 0
***it RW = P2^1;
***it RS = P3^7;
***it EN = P2^0;
void LcdInit(void);
extern void Lcd1602WriteData(unsigned char Data);
extern void Lcd1602WriteCommand(unsigned char Command);
static void Delay(void);
void Lcd1602WriteCommand(unsigned char Command)
{
unsigned char i;
unsigned char Lcd;
RS = LCD_WRITE;
WAIT();
RW = LCD_CMD;
WAIT();
for(i = 0;i < 8;i++)
{
Lcd<<=1;
Lcd |= Command&0x01;
Command>>=1;
}
GPIO_LCD = Lcd;
EN = 1;
Delay();
EN = 0;
}
void Lcd1602WriteData(unsigned char Data)
{
unsigned char i;
unsigned char Lcd;
RS = LCD_DAT;
WAIT();
RW = LCD_WRITE;
WAIT();
for(i = 0;i < 8;i++)
{
Lcd<<=1;
Lcd |= Data&0x01;
Data>>=1;
}
GPIO_LCD = Lcd;
EN = 1;
Delay();
EN = 0;
}
static void Delay(void)
{
unsigned char i, j;
_nop_();
i = 11;
j = 19;
do
{
while (--j);
} while (--i);
}
void LcdInit(void)
{
Lcd1602WriteCommand(0x38); //16*2,8位数据接口
Lcd1602WriteCommand(0x0c); //开启显示,光标不显示、不闪烁
Lcd1602WriteCommand(0x40); //数据指针自增1,字符不移动
Lcd1602WriteCommand(0x06);
Lcd1602WriteCommand(0x01); //清屏
Lcd1602WriteCommand(0x80); //数据指针指向第一行第一个字符
}
//我吧两个文件合在一起了。
#ifndef _LCD1602_H_
#define _LCD1602_H_
#include "reg51.h"
#include "intrins.h"
#define NOP _nop_()
#define GPIO_LCD P1
#define WAIT() NOP,NOP,NOP,NOP;
#define LCD_WRITE 0
#define LCD_READ 1
#define LCD_DAT 1
#define LCD_CMD 0
***it RW = P2^1;
***it RS = P3^7;
***it EN = P2^0;
void LcdInit(void);
extern void Lcd1602WriteData(unsigned char Data);
extern void Lcd1602WriteCommand(unsigned char Command);
static void Delay(void);
void Lcd1602WriteCommand(unsigned char Command)
{
unsigned char i;
unsigned char Lcd;
RS = LCD_WRITE;
WAIT();
RW = LCD_CMD;
WAIT();
for(i = 0;i < 8;i++)
{
Lcd<<=1;
Lcd |= Command&0x01;
Command>>=1;
}
GPIO_LCD = Lcd;
EN = 1;
Delay();
EN = 0;
}
void Lcd1602WriteData(unsigned char Data)
{
unsigned char i;
unsigned char Lcd;
RS = LCD_DAT;
WAIT();
RW = LCD_WRITE;
WAIT();
for(i = 0;i < 8;i++)
{
Lcd<<=1;
Lcd |= Data&0x01;
Data>>=1;
}
GPIO_LCD = Lcd;
EN = 1;
Delay();
EN = 0;
}
static void Delay(void)
{
unsigned char i, j;
_nop_();
i = 11;
j = 19;
do
{
while (--j);
} while (--i);
}
void LcdInit(void)
{
Lcd1602WriteCommand(0x38); //16*2,8位数据接口
Lcd1602WriteCommand(0x0c); //开启显示,光标不显示、不闪烁
Lcd1602WriteCommand(0x40); //数据指针自增1,字符不移动
Lcd1602WriteCommand(0x06);
Lcd1602WriteCommand(0x01); //清屏
Lcd1602WriteCommand(0x80); //数据指针指向第一行第一个字符
}
//我吧两个文件合在一起了。
举报