日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 技術(shù)學(xué)院 > 熱搜器件
[導(dǎo)讀]這是1302的C文件,1302.h文件在后來(lái)面#include"1302.h"code unsigned char write_rtc_address[7]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c}; //秒分時(shí)日月周年 最低位讀寫(xiě)位code unsigned char read_rtc_address[7]={0x

這是1302的C文件,1302.h文件在后來(lái)面

#include"1302.h"

code unsigned char write_rtc_address[7]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c}; //秒分時(shí)日月周年 最低位讀寫(xiě)位

code unsigned char read_rtc_address[7]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};

void Write_Ds1302_Byte(unsigned char temp)

{

unsigned char i;

for (i=0;i<8;i++) //循環(huán)8次 寫(xiě)入數(shù)據(jù)

{

sclk=0;

io=temp&0x01; //每次傳輸?shù)妥止?jié)

temp>>=1; //右移一位

sclk=1;

}

}

/******************************************************************/

/* 寫(xiě)入DS1302 */

/******************************************************************/

void Write_Ds1302( unsigned char address,unsigned char dat )

{

rst=0;

_nop_();

sclk=0;

_nop_();

rst=1;

_nop_(); //啟動(dòng)

Write_Ds1302_Byte(address); //發(fā)送地址

Write_Ds1302_Byte(dat); //發(fā)送數(shù)據(jù)

rst=0; //恢復(fù)

}

/******************************************************************/

/* 讀出DS1302數(shù)據(jù) */

/******************************************************************/

unsigned char Read_Ds1302 ( unsigned char address )

{

unsigned char i,temp=0x00;

rst=1;

_nop_();

_nop_();

Write_Ds1302_Byte(address);

for (i=0;i<8;i++) //循環(huán)8次 讀取數(shù)據(jù)

{

if(io)

temp|=0x80; //每次傳輸?shù)妥止?jié)

sclk=1;

temp>>=1; //右移一位

_nop_();

_nop_();

_nop_();

sclk=0;

}

rst=0;

_nop_(); //以下為DS1302復(fù)位的穩(wěn)定時(shí)間

_nop_();

rst=0;

sclk=0;

_nop_();

_nop_();

_nop_();

_nop_();

/*sclk=1;

_nop_();

_nop_();

io=0;

_nop_();

_nop_();

io=1;

_nop_();

_nop_(); */

return (temp); //返回

}

/******************************************************************/

/* 讀時(shí)鐘數(shù)據(jù) */

/******************************************************************/

uchar Read_RTC1(uchar j) //讀取 日歷

{

uchar c;

unsigned char *p;

p=&read_rtc_address[j]; //地址傳遞

c=Read_Ds1302(*p);

c=(( c&0x70)>>4)*10 + ( c&0x0F);

return(c);

}

/******************************************************************/

/* 設(shè)定時(shí)鐘數(shù)據(jù) */

/******************************************************************/

void Set_RTC(uchar a,uint c) //設(shè)定 日歷

{

unsigned char *p ,shi,ge ;

Write_Ds1302(0x8E,0X00);

shi=a/10;

ge=a%10;

a=shi*16+ge;

p=&write_rtc_address[c]; //傳地址

Write_Ds1302(*p,a) ;

// Write_Ds1302(0x8E,0x80);

} 、

這是頭文件:

#include

#include

#define uchar unsigned char

#define uint unsigned int

sbit sclk=P1^2; //時(shí)鐘

sbit io=P1^1; //數(shù)

sbit rst = P1^0;

void Set_RTC(uchar a,uint c);

uchar Read_RTC1(uchar j);

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉