这个是主程序,大家可以参考。
#include "reg52.h"
#include "ds1302.h"
#include "intrins.h"
sbit A2=P3^0;
sbit A3=P3^1;
unsigned char write_ds1302_adrr[7] = {0x80,0x82,0x84,0x86,0x88,0x8a,0x8c};
unsigned char read_ds1302_adrr[7] = {0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
unsigned char time[7]={0x54,0x59,0x11,0x22,0x01,0x06,0x22};
void Delay(unsigned int xms);
void ds1302_config()
{
unsigned char i=0;
Write_Ds1302(0x8e,0x00);
for(i;i<7;i++)
{
Write_Ds1302(write_ds1302_adrr[i],time[i]);
}
Write_Ds1302(0x8e,0x80);
}
void ds1302_read_time()
{
unsigned char i=0;
for(i;i<7;i++)
{
time[i]=Read_Ds1302(read_ds1302_adrr[i]);
}
}
unsigned char code SMG_duanma[16]=
{0xC0,0xF9,0xA4