unsigned char timebuf[3]={0x02,0x05,0x15};//时分秒 unsigned char shi,fen,miao;//注意在ds1302.c中定义,在ds1302.h中,用extern修饰一下 void ds1302init(void) { Write_Ds1302_Byte(0x8E,0x00);//关闭写保护 Write_Ds1302_Byte(0x8C,0x23);//年,23代表是20xx的2023年; Write_Ds1302_Byte...
如上所示,写字节函数 WrByte_1302()中,要求单片机在时钟 SCLK_1302 上升沿前将数据放到数据总线 IO_1302 上,然后产生一个 SCLK_1302 上升,完成一 bit 数据的写入,同时要求 1Byte 的数据低位在前,高位在后依次发送。读字节函数 RdByte_1302()中,要求在时钟 SCLK_1302 下降沿之后,将总线 IO_1302 数据读出,...
voidDS1302_WriteByte(unsignedcharaddr, unsignedchardat) { unsignedcharn; RST=0; _nop_(); SCLK=0; _nop_(); RST=1; _nop_();for(n=0; n<8; n++)//发送要写入数据的内存地址{ DSIO= addr &0x01; addr>>=1; SCLK=1; _nop_(); SCLK=0; _nop_(); }for(n=0; n<8; n++)//...
Data = ReadByteDS1302(); T_CLK = 1; T_RST = 0; return(Data); } void DS1302_INI() //设置ds1302函数,初始化时间和日期 { WriteDS1302(0x8e,0x00); //关闭写保护,允许写操作 WriteDS1302(0x80,0x51); //秒 WriteDS1302(0x82,0x59); //分 WriteDS1302(0x84,0x12); //时 WriteDS1...
voidDS1302_WriteByte(unsignedcharaddr,unsignedchardat){unsignedcharn; RST =0; SCLK =0; RST =1;for(n=0; n<8; n++) { DSIO = addr &0x01; addr >>=1; SCLK =1; SCLK =0; }for(n=0; n<8; n++) { DSIO = dat &0x01; ...
u8codet_display[]={//标准字库// 0 1 2 3 4 5 6 7 8 9 A B C D E F0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,//black - H J K L N o P U t G Q r M y0x00,0x40,0x76,0x1E,0x70,0x38,0x37,0x5C,0x73,0x3E,0x78...
添加DS1302_WriteByte(0x8E,0x00); #include <REGX52.H> #include "LCD1602.h" #include "DS1302.h" #include "Delay.h" unsigned char Second; void main() { LCD_Init(); DS1302_Init(); LCD_ShowString(1,1,"RTC"); DS1302_WriteByte(0x8E,0x00); ...
void Ds1302_Single_Byte_Write(unsigned char addr, unsigned char dat) { RST_CLR; /*RST脚置低,实现DS1302的初始化*/SCK_CLR; /*SCK脚置低,实现DS1302的初始化*/RST_SET; /*启动DS1302总线,RST=1电平置高 */ addr = addr & 0xFE;
void ds1302_writeByte(u8 dat); //写一个字节 void ds1302_writeData(u8 addr,u8 dat); //向指定地址寄存器写数据 #endif #include "ds1302.h" data u8 timeData[7]={10,6,4,17,11,20,55}; code u8 writeAddr[7]={0x8c,0x8a,0x88,0...
if ((value & 0x01) != 0){ GPIO_WriteBit(DS1302_DATA_PORT, DS1302_DATA_BIT, Bit_SET);}...