DS1302怎么设置多组闹钟。。。加急急急!毕设
时间:10-02
整理:3721RD
点击:
DS1302怎么设置多组闹钟。急急急!毕设
谁做过用DS1302做闹钟,可以设置多个闹铃。加急加急。毕设作品。
我这样做不行:
if(s5==0&&s1num==0)
{
s5num++;
flag2=1;
while(!s5);baojing();
if(s5num==1)
{ write_com(0x80+13);
write_com(0x0f);//光标
}
if(s5num==2)
{
write_1302(0x8e,0x00);//禁止写保护,第一组闹铃分钟
write_1302(0xc2,lfen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0x80+10);
}
if(s5num==3)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc0,lshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+2);
}
if(s5num==4)
{
write_1302(0x8e,0x00);//禁止写保护,第二组闹铃
write_1302(0xc4,eshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+5);
}
if(s5num==5)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc6,efen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+7);
}
if(s5num==6)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc8,sshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+10);
}
if(s5num==7)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xca,sfen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+12);
}
if(s5num==8)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xcc,sishi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+15);
}
if(s5num==9)
{
s5num=0;
flag2=0;
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xce,sifen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0x0c);//不显示光标
}
}
}
/***********************以下是加减*************************/
if(s5num!=0&&s1num==0)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);baojing();
if(s5num==1)
{
uchar *fff1=&lfen;
fenjia(fff1,12,0x80+13);
}
if(s5num==2)
{
uchar *sss1=&lshi;
shijia(sss1,9,0x80+10);
}
if(s5num==4)
{
uchar *sss2=&eshi;
shijia(sss2,1,0xc0+2);
}
if(s5num==4)
{
uchar *fff2=&efen;
fenjia(fff2,4,0xc0+5);
}
if(s5num==5)
{
uchar *sss1=&sshi;
shijia(sss1,9,0xc0+10);
}
if(s5num==6)
{
uchar *fff1=&sfen;
fenjia(fff1,12,0xc0+13);
}
if(s5num==7)
{
uchar *sss1=&sishi;
shijia(sss1,9,0xc0+10);
}
if(s5num==8)
{
uchar *fff1=&sifen;
fenjia(fff1,12,0xc0+13);
}
}
}
谁做过用DS1302做闹钟,可以设置多个闹铃。加急加急。毕设作品。
我这样做不行:
if(s5==0&&s1num==0)
{
s5num++;
flag2=1;
while(!s5);baojing();
if(s5num==1)
{ write_com(0x80+13);
write_com(0x0f);//光标
}
if(s5num==2)
{
write_1302(0x8e,0x00);//禁止写保护,第一组闹铃分钟
write_1302(0xc2,lfen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0x80+10);
}
if(s5num==3)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc0,lshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+2);
}
if(s5num==4)
{
write_1302(0x8e,0x00);//禁止写保护,第二组闹铃
write_1302(0xc4,eshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+5);
}
if(s5num==5)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc6,efen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+7);
}
if(s5num==6)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xc8,sshi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+10);
}
if(s5num==7)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xca,sfen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+12);
}
if(s5num==8)
{
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xcc,sishi);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0xc0+15);
}
if(s5num==9)
{
s5num=0;
flag2=0;
write_1302(0x8e,0x00);//禁止写保护
write_1302(0xce,sifen);//闹钟初始化
write_1302(0x8e,0x80);//开写保护
write_com(0x0c);//不显示光标
}
}
}
/***********************以下是加减*************************/
if(s5num!=0&&s1num==0)
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);baojing();
if(s5num==1)
{
uchar *fff1=&lfen;
fenjia(fff1,12,0x80+13);
}
if(s5num==2)
{
uchar *sss1=&lshi;
shijia(sss1,9,0x80+10);
}
if(s5num==4)
{
uchar *sss2=&eshi;
shijia(sss2,1,0xc0+2);
}
if(s5num==4)
{
uchar *fff2=&efen;
fenjia(fff2,4,0xc0+5);
}
if(s5num==5)
{
uchar *sss1=&sshi;
shijia(sss1,9,0xc0+10);
}
if(s5num==6)
{
uchar *fff1=&sfen;
fenjia(fff1,12,0xc0+13);
}
if(s5num==7)
{
uchar *sss1=&sishi;
shijia(sss1,9,0xc0+10);
}
if(s5num==8)
{
uchar *fff1=&sifen;
fenjia(fff1,12,0xc0+13);
}
}
}
设置多组闹钟与DS1302没有关系,看你的程序怎么写,DS1302只要负责提供当前时间就可以了,闹钟的实现用程序做时间对比即可,实现n组闹钟都可以
我想的是,用加减按键可以随时调整闹铃,用1602可以查看多组闹钟
我设计的是把闹针时间值写入ds1302的RAM中,再读出RAM的值,在程序中实现闹钟功能。在实践中好用。
DS1302的闹钟和报时,以及其他数据调整都要保存到1302的RAM中,然后读出到单片机中处理。
如果改为8563的话其他功能更好实现。《请参考PCF8563资料》