#ifndef _LCD1602_H_
#define _LCD1602_H_
#include <reg52.h>
/* 定义单片机的管脚 */
#define LCD1602_DATAPINS P0 //P0口用来发送数据,一整个字节地发送
sbit LCD1602_RS = P2^6; //P26口声明P0口发的是数据还是命令,1为数据,0为命令
sbit LCD1602_RW = P2^5; //P25口声明现在是将数据写入LCD显示屏,还是从LCD读出数据。1为读,0为写
sbit LCD1602_E = P2^7; //P27口为LCD的使能端,高电平有效
/* 定义LCD使用4位数据管脚的宏,如果使用4位数据管脚的LCD,就打开下面的注释 */
// #define LCD1602_4DATAPINS
/* 函数声明 */
void LCD1602_WriteInstrucion(unsigned char i);
void LCD1602_Init();
void LCD1602_WriteData(unsigned char dat);
void LCD1602_WriteSfm(unsigned char sfm);
void LCD1602_WriteCom(unsigned char com);
void LCD_Delay(unsigned int i);
void write_sfm(unsigned char sfm);
#endif
#include<reg52.h>
#include<lcd1602.h>
#define uchar unsigned char
#define uint unsigned int
uchar int_time;
uchar second;
uchar minute;
uchar hour;
uchar code date[]="H.I.T.CHINA";
uchar code time[]="TIME 23:59:55";
uchar second=55,minute59,hour=23;
void write_data();
void clock_init()
{
uchar i,j;
for(i=0;i<16;i++)
{
write_data(date[ i]);
}
write_com(0x80+0x40);
for(j=0;j<16;j++)
{
write_data(time[j]);
}
}
void clock_write(uint s,uint m,uint h)
{
write_sfm(0x47,h);
write_sfm(0x4a,m);
write_sfm(0x4d,s);
}
void main()
{
init1602();
clock_init();
TMOD=0x01;
EA=1;
ET0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
int_time=0;
second=55;
minute=59;
hour=23;
while(1)
{
clock_write(seconf,minute,hour);
}
}
void T0_interserve(void) interrupt 1 using 1
{ int_time++;
if(int_time==20)
{
int_time=0;
second++;
}
if(second==60)
{
second=0;
minute++;
}
if(minute==60)
{
minute=0;
hour++;
}
if(hour==24)
{
hour=0;
}
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
}
B1103.C(18): error C267: 'write_data': requires ANSI-style prototype |