#include <HEAD.H>
sbit SCK=P1^7;
sbit SDA=P2^3;
sbit RST = P1^3; // DS1302复位
int i=0,hour,min,s;
void shan()
{
BCD(hour,2);
BCD(min,1);
BCD(s,0);
if((temp[0]==wei[0])&&(temp[1]==wei[1])&&(temp[2]==wei[2]))
{
P2=0X80;P0=0Xff;P01=0;
}
}
void main()
{
int TF,liang;
int hour1,hour2,min1,min2,s1,s2;
P2=0XA0;P0=0X00;
s6=s7=s5=s4=1;
ds1302init();
// AUXR|=0X80;
// TMOD&=0XF0;
// TH0=0X28;
// TL0=0X00;
// TF0=0;
// TR0=1;
while(1)
{
read_ds1302();
seg(2);
BUG();
if(liang==1)
{
shan();
}
if(flag_bug==1)
{
while(1)
{
SCK=0;
SDA=0;
RST=1; //复位
BUG();
if(flag_bug==1) //修改时的第一位
{
TF=1;
if(s5==0)
{
hour1=hour1+1;
if(hour1>2)
{
hour1=0;
}
while(s5==0);
}
else if(s4==0)
{
hour1=hour1-1;
if(hour1<0)
{
hour1=0;
}
while(s4==0);
}
}
else if(flag_bug==2) //修改时的第二位
{
TF=2;
if(s5==0)
{
hour2=hour2+1;
if(hour2>9)
{
hour2=0;
}
while(s5==0);
}
else if(s4==0)
{
hour2=hour2-1;
if(hour2<0)
{
hour2=0;
}
while(s4==0);
}
}
else if(flag_bug==3) //修改MIN的第一位
{
TF=3;
if(s5==0)
{
min1=min1+1;
if(min1>5)
{
min1=0;
}
while(s5==0);
}
else if(s4==0)
{
min1=min1-1;
if(min1<0)
{
min1=0;
}
while(s4==0);
}
}
else if(flag_bug==4) //修改min的第二位
{
TF=4;
if(s5==0)
{
min2=min2+1;
if(min2>9)
{
min2=0;
}
while(s5==0);
}
else if(s4==0)
{
min2=min2-1;
if(min2<0)
{
min2=0;
}
while(s4==0);
}
}
else if(flag_bug==5) //s的第一位
{
TF=5;
if(s5==0)
{
s1=s1+1;
if(s1>5)
{
s1=0;
}
while(s5==0);
}
else if(s4==0)
{
s1=s1-1;
if(s1<0)
{
s1=0;
}
while(s4==0);
}
}
else if(flag_bug==6) //s的第二位
{
TF=6;
if(s5==0)
{
s2=s2+1;
if(s2>9)
{
s2=0;
}
while(s5==0);
}
else if(s4==0)
{
s2=s2-1;
if(s2<0)
{
s2=0;
}
while(s4==0);
}
}
shu[0]=smgduan[s2]; //S ///修改时间的显示
shu[1]=smgduan[s1];
shu[2]=~(0x40);
shu[3]=smgduan[min2];
shu[4]=smgduan[min1];// MIN
shu[5]=~(0x40);
shu[6]=smgduan[hour2]; //HOUR
shu[7]=smgduan[hour1];
seg(2);
if(flag_bug==7) //设置成功
{
hour=hour1*10+hour2;
min=min1*10+min2;
s=s1*10+s2;
BCD(hour,2);
BCD(min,1);
BCD(s,0);
Write_Ds1302(0x8e,0x00);
for(i=0;i<3;i++)
{
Write_Ds1302(timeaddr[i],temp[i]);
}
Write_Ds1302(0x8e,0x80);
TF=0;
break;
}
} //
}
if(flag_bug==10)
{
liang=1;
while(1)
{
BUG();
if(flag_bug==10) //修改时的第一位
{
TF=1;
if(s5==0)
{
hour1=hour1+1;
if(hour1>2)
{
hour1=0;
}
while(s5==0);
}
else if(s4==0)
{
hour1=hour1-1;
if(hour1<0)
{
hour1=0;
}
while(s4==0);
}
}
else if(flag_bug==11) //修改时的第二位
{
TF=2;
if(s5==0)
{
hour2=hour2+1;
if(hour2>9)
{
hour2=0;
}
while(s5==0);
}
else if(s4==0)
{
hour2=hour2-1;
if(hour2<0)
{
hour2=0;
}
while(s4==0);
}
}
else if(flag_bug==12) //修改MIN的第一位
{
TF=3;
if(s5==0)
{
min1=min1+1;
if(min1>5)
{
min1=0;
}
while(s5==0);
}
else if(s4==0)
{
min1=min1-1;
if(min1<0)
{
min1=0;
}
while(s4==0);
}
}
else if(flag_bug==13) //修改min的第二位
{
TF=4;
if(s5==0)
{
min2=min2+1;
if(min2>9)
{
min2=0;
}
while(s5==0);
}
else if(s4==0)
{
min2=min2-1;
if(min2<0)
{
min2=0;
}
while(s4==0);
}
}
else if(flag_bug==14) //s的第一位
{
TF=5;
if(s5==0)
{
s1=s1+1;
if(s1>5)
{
s1=0;
}
while(s5==0);
}
else if(s4==0)
{
s1=s1-1;
if(s1<0)
{
s1=0;
}
while(s4==0);
}
}
else if(flag_bug==15) //s的第二位
{
TF=6;
if(s5==0)
{
s2=s2+1;
if(s2>9)
{
s2=0;
}
while(s5==0);
}
else if(s4==0)
{
s2=s2-1;
if(s2<0)
{
s2=0;
}
while(s4==0);
}
}
shu[0]=smgduan[s2]; //S ///修改时间的显示
shu[1]=smgduan[s1];
shu[2]=~(0x40);
shu[3]=smgduan[min2];
shu[4]=smgduan[min1];// MIN
shu[5]=~(0x40);
shu[6]=smgduan[hour2]; //HOUR
shu[7]=smgduan[hour1];
seg(2);
hour=hour1*10+hour2;
min=min1*10+min2;
s=s1*10+s2;
if(flag_bug==16)
{
break;
}
}
}
}
}
//
//void time11() interrupt 1
//{
// uint count,FF=0x01;
// count++;
// if(count==200)
// {
// if(TF==1)
// {
// P2=0XC0;P0=0X00;P0=0X01; P2=0XFF;P0=0XFF;P0=shu[7];
// }
// else if(TF==2)
// {
// P2=0XC0;P0=0X00;P0=0X02; P2=0XFF;P0=0XFF;P0=shu[6];
// }
// else if(TF==3)
// {
// P2=0XC0;P0=0X00;P0=0X08; P2=0XFF;P0=0XFF;P0=shu[4];
// }
// else if(TF==4)
// {
// P2=0XC0;P0=0X00;P0=0X10; P2=0XFF;P0=0XFF;P0=shu[3];
// }
// else if(TF==5)
// {
// P2=0XC0;P0=0X00;P0=0X40; P2=0XFF;P0=0XFF;P0=shu[1];
// }
// else if(TF==6)
// {
// P2=0XC0;P0=0X00;P0=0X80; P2=0XFF;P0=0XFF;P0=shu[0];
// }
// count=0;
// }
//}
没有合适的资源?快使用搜索试试~ 我知道了~
Ds1302时钟(2017).zip_C51
共28个文件
c:4个
h:4个
lst:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 201 浏览量
2022-09-24
23:48:06
上传
评论
收藏 62KB ZIP 举报
温馨提示
DS1302时钟芯片的应用(设置时间,闹钟,功能并不完整),仅供参考,有问题希望指出。
资源推荐
资源详情
资源评论
收起资源包目录
Ds1302时钟(2017).zip (28个子文件)
Ds1302时钟(2017)
main.OBJ 18KB
ds1302时钟 35KB
ds1302时钟_uvproj.bak 13KB
ds1302.h 215B
ds1302.OBJ 8KB
ds1302时钟.plg 1KB
ds1302时钟.uvproj 13KB
main.c 7KB
HEAD.H 620B
ds1302时钟.lnp 58B
ALL.OBJ 15KB
main.LST 33KB
ALL.c 4KB
18b20.c 0B
cc.uvproj 574B
ALL.LST 9KB
cc_uvproj.bak 0B
ds1302时钟.uvopt 55KB
ds1302.c 1KB
ds1302时钟.M51 29KB
ALL.H 61B
ds1302.__i 36B
STC15F2K60S2.H 13KB
ALL.__i 33B
cc.uvopt 49KB
ds1302时钟_uvopt.bak 56KB
ds1302时钟.hex 10KB
ds1302.LST 3KB
共 28 条
- 1
资源评论
alvarocfc
- 粉丝: 112
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功