void GET_TIME_DS1302(char *hour , char *min , char *mon , char *date)
{
uchar ho,mi,mo,da;
ho = RW_DATA_DS1302(0x83); //read min
mi = RW_DATA_DS1302(0x85); //read hour
mo = RW_DATA_DS1302(0x87); //read date
da = RW_DATA_DS1302(0x89); //read mon
*hour = ho;
*min = mi;
*mon = mo;
*date = da;
}
#include"STC12.H"
#include"74HC595.H"
#include"DS1302.H"
#define uchar unsigned char
#define uint unsigned int
void main ()
{
char hour,min,mon,date;
SET_TIME_DS1302();
while(1)
{
GET_TIME_DS1302(& hour ,& min ,& mon ,& date);
if(min < 0x01)//看取出的分钟是否小于0x01
{
WR_595(0xff);//是的话就让74hc595全部输出1
OUT_595();
}
else
{
WR_595(0x0f);//是的话就让74hc595 4个通道输出1
OUT_595();
}
}
}
这样写看着舒服点 |