ds1302时钟保护程序怎么写,如果能加调时,闹钟功能就更好了

来源:百度知道 编辑:UC知道 时间:2024/06/10 14:02:26

#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit SCK=P3^6;
sbit SDA=P3^4;
sbit RST=P3^5;// DS1302复位
sbit set=P3^0;//定义按键端口
sbit s1=P3^1;
sbit s2=P3^2;
sbit s3=P3^3;
/************液晶口定义*******/
sbit RS=P2^4;//RS为数据/指令选择1/0
sbit RW=P2^5;//读写
sbit E=P2^6;//E为使能信号
bit flag;//是否读取时间的标志位
uchar setn=0;//复位键、增加键、减少键按下次数
uchar code time0[]="DATE: - - ";
uchar code time1[]="TIME: : : ";
uchar l_tmpdate[7]={0,55,16,22,8,6,9};//秒分时日月周年// 可随时更改
uchar code write_add[7]={0x80,0x82,0x84,0x86,
0x88,0x8a,0x8c}; //秒分时日月周年 写的寄存器地址
uchar code read_add[7]={0x81,0x83,0x85,0x87,
0x89,0x8b,0x8d}; //秒分时日月周年 读的寄存器地址
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d
,0x7d,0x07,0x7f,0x6f,0x40}; //共阴数码管 0-9加'-'熄灭表
void delay(uint z)
{
while(--z);
}
void write_com(