主函数文件:
#include <reg52.h>
#include "./delay/delay.h"
#define ds1302_sec_add 0x80
#define ds1302_min_add 0x82
#define ds1302_hr_add 0x84
#define ds1302_date_add 0x86
#define ds1302_month_add 0x88
#define ds1302_day_add 0x8a
#define ds1302_year_add 0x8c
#define ds1302_charger_add 0x90
#define ds1302_control_add 0x8e
#define ds1302_clkburst_add 0xbe
sbit RST = P1^0;
sbit SCK = P1^1;
sbit IO = P1^2;
sbit RS = P2^4;
sbit RW = P2^5;
sbit E = P2^6;
#define LCDPORT P0
#define LCD_WRITE_DATA 1
#define LCD_WRITE_COM 0
unsigned char timebuf[7] = {16,48,40,16,8,17,3};
unsigned char tempbuf[3];
unsigned char writebuf[7];
unsigned char readbuf[7];
unsigned char disbuf[3];
void lcd1602_write(unsigned char byte,unsigned char flag)
{
if(flag)
{
RS = 1;
}
else
{
RS = 0;
}
RW = 0;
E = 1;
LCDPORT = byte;
delay_us(