#include"REG51.H" #include"INTRINS.H" typedefunsignedcharBYTE; sbitSCLK=P1^0;//DS1302时钟口P1.0 sbitIO=P1^1;//DS1302数据口P1.1 sbitRST=P1^2;//DS1302片选口P1.2 //秒分时日月星期年 BYTEcodeinit[]={0x00,0x00,0x20,0x01,0x01,0x05,0x10}; BYTEdatanow[7]; voidDS1302_Initial(); voidDS1302_SetTime(BYTE*p); voidDS1302_GetTime(BYTE*p); voidmain() { DS1302_Initial();//初始化DS1302 DS1302_SetTime(init);//设置初始时间 DS1302_GetTime(now);