#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit SCL = P3^6; //定义时钟信号接口
sbit IO = P3^4; //定义数据信号接口
sbit RST = P3^5; //定义复位信号接口
sbit ACC0 = ACC^0; //ACC寄存器的最低位
sbit ACC7 = ACC^7; //ACC寄存器的最高位
uchar ds1,ds2,time;
uchar curttime[7];
//数码管显示字符表
uchar code table[] = {
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71
};
//初始化时间表
uchar code InitTime[] = {0x01,0x20,0x02,0x16,0x10,0x06,0x10,
};
//段选表
uchar code tabwcon[] ={0x07,0x06,0x05,0x04,
0x03,0x02,0x01,0x00};
//读取时间的地址表
uchar code read_time_address[7]={
0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
//写入时间的地址表
code uchar write_rtc_address[7]={
0x80,0x82,0x84,0x86,0x88,0x8a,0x8c};
//数码管显示延时函数
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
{
for(y=190;y>0;y--);
{
}
}
}
//发送一个字节
void SendByte(uchar date)
{
uchar i;
ACC = date; //将date变量存入ACC中
for (i = 8; i >0; i--)
{