#ifndef __LCD1602_H__
#define __LCD1602_H__
//#include "delay.h"
#include<reg52.h>
sbit LCD1602_RS = P3^6;
sbit LCD1602_RW = P3^5;
sbit LCD1602_E = P3^4;
#define Busy 0x80
#define LCD1602_Data P0
void delay_50us_1602(unsigned int t)
{
unsigned char i,j;
for(i=0;i<t;i++)
for(j=110;j>0;j--);
}
void LCD1602_write_com(unsigned char com)
{
delay_50us_1602(5);
// LCD1602_E = 0;
LCD1602_RS = 0;
LCD1602_RW = 0;
LCD1602_E = 0;
LCD1602_Data= com;
delay_50us_1602(10);
LCD1602_E = 1;
delay_50us_1602(10);
LCD1602_E = 0;
}
void LCD1602_write_data(unsigned char dat)
{
delay_50us_1602(10);
// LCD1602_E = 0;
LCD1602_RS = 1;
LCD1602_RW = 0;
LCD1602_E = 0;
LCD1602_Data = dat;
delay_50us_1602(10);
LCD1602_E = 1;
delay_50us_1602(10);
LCD1602_E = 0;
}
void LCD1602_init(void)
{
delay_50us_1602(15);
LCD1602_write_com(0X38);
delay_50us_1602(5);
// LCD1602_write_com(0X0C);
// LCD1602_write_com(0X06);
// LCD1602_write_com(0X01);
LCD1602_write_com(0X08);
delay_50us_1602(5);
LCD1602_write_com(0X01);
delay_50us_1602(5);
LCD1602_write_com(0X06);
delay_50us_1602(5);
LCD1602_write_com(0X0C);
delay_50us_1602(5);
// LCD1602_write_com(0x0e);
// LCD1602_write_com(0x06);
// LCD1602_write_com(0x01);
}
void LCD1602_Disp_ZF(unsigned char addr,unsigned char * pt,unsigned char num)
{
unsigned char i;
LCD1602_write_com(addr);
for(i = 0;i < (num*1);i++)
LCD1602_write_data(*(pt++));
}
#endif
void main(void)
{
Delay_ms(400);
LCD1602_init();
Delay_ms(10);
LCD1602_Disp_ZF(0x80," CM CM",16);
LCD1602_Disp_ZF(0x80+0X40,"sdz: CM",16);
TMOD=0x01;
TH0=0;
TL0=0;
TH1=0xf8;
TL1=0x30;
ET0=1;
ET1=1;
TR1=1;
EA=1;
// EA=0;
sdz = ISP_READ(0x2c00)*256+ISP_READ(0x2c01);
EA=1;
|