//從DS302讀出時鐘數(shù)據(jù)
void DS1302_Read_Time(void)
{
time_buf[1] = DS1302_Read_Byte(ds1302_year_add); //年
time_buf[2] = DS1302_Read_Byte(ds1302_month_add); //月
time_buf[3] = DS1302_Read_Byte(ds1302_date_add); //日
time_buf[4] = DS1302_Read_Byte(ds1302_hr_add); //時
time_buf[5] = DS1302_Read_Byte(ds1302_min_add); //分
time_buf[6] = (DS1302_Read_Byte(ds1302_sec_add))&0x7f; //秒,屏蔽秒的第7位,避免超出59
time_buf[7] = DS1302_Read_Byte(ds1302_day_add); //周
}
//DS1302向上層返回時間數(shù)據(jù)
void DS1302_Get_Time(u8 *time)
{
DS1302_Read_Time();
time[0]=(time_buf[0]>>4); //年
time[1]=(time_buf[0]&0x0f);
time[2]=(time_buf[1]>>4);
time[3]=(time_buf[1]&0x0f);
time[4]=(time_buf[2]>>4); //月
time[5]=(time_buf[2]&0x0f);
time[6]=(time_buf[3]>>4); //日
time[7]=(time_buf[3]&0x0f);
time[8]=(time_buf[7]&0x07); //星期
time[9]=(time_buf[4]>>4); //時
time[10]=(time_buf[4]&0x0f);
time[11]=(time_buf[5]>>4); //分
time[12]=(time_buf[5]&0x0f);
time[13]=(time_buf[6]>>4); //秒
time[14]=(time_buf[6]&0x0f);
}
更新日期時間數(shù)組的部分程序有問題。。。。沒這硬件。。。。。調(diào)試原始的數(shù)據(jù)吧,看看具體哪讀的問題