《電子技術(shù)應(yīng)用》
您所在的位置:首頁 > 嵌入式技術(shù) > 解決方案 > 日歷時(shí)鐘DS12887或146818的C語言源程序

日歷時(shí)鐘DS12887或146818的C語言源程序

2009-01-16
關(guān)鍵詞: 源程序 單片機(jī)

日歷時(shí)鐘DS12887或146818的C語言源程序

#define uchar unsigned char
#define uint unsigned int
#i nclude <reg52.h>
#i nclude <stdio.h>
#i nclude <absacc.h>
#i nclude <math.h>
#i nclude <string.h>
#i nclude <ctype.h>
#i nclude <stdlib.h>

#define P128870 XBYTE[0xa000]
#define P128871 XBYTE[0xa001]
#define P128872 XBYTE[0xa002]
#define P128873 XBYTE[0xa003]
#define P128874 XBYTE[0xa004]
#define P128875 XBYTE[0xa005]
#define P128876 XBYTE[0xa006]
#define P128877 XBYTE[0xa007]
#define P128878 XBYTE[0xa008]
#define P128879 XBYTE[0xa009]
#define P12887a XBYTE[0xa00a]
#define P12887b XBYTE[0xa00b]
#define P12887c XBYTE[0xa00c]
#define P12887d XBYTE[0xa00d]
#define P12887e XBYTE[0xa00e]
#define P12887f XBYTE[0xa00f]

void setup12887(uchar *p);
void read12887(uchar *p);
void start12887(void);

void setup12887(uchar *p) //設(shè)置系統(tǒng)時(shí)間
{
uchar i;
i=P12887d;
P12887a=0x70; P12887b=0xa2; P128870=*p++; P128871=0xff; P128872=*p++;
P128873=0xff; P128874=*p++; P128875=0xff; P128876=*p++; P128877=*p++;
P128878=*p++; P128879=*p++; P12887b=0x22; P12887a=0x20;
i=P12887c;
}
void read12887(uchar *p) //讀取系統(tǒng)時(shí)間
{
uchar a;
do{ a=P12887a; } while((a&0x80)==0x80);
*p++=P128870; *p++=P128872; *p++=P128874; *p++=P128876;
*p++=P128877; *p++=P128878; *p++=P128879;
}
void start12887(void) //啟動(dòng)時(shí)鐘
{
uchar i;
i=P12887d;
P12887a=0x70; P12887b=0xa2; P128871=0xff; P128873=0xff; P128875=0xff;
P12887b=0x22; P12887a=0x20;
i=P12887c;
}
 

本站內(nèi)容除特別聲明的原創(chuàng)文章之外,轉(zhuǎn)載內(nèi)容只為傳遞更多信息,并不代表本網(wǎng)站贊同其觀點(diǎn)。轉(zhuǎn)載的所有的文章、圖片、音/視頻文件等資料的版權(quán)歸版權(quán)所有權(quán)人所有。本站采用的非本站原創(chuàng)文章及圖片等內(nèi)容無法一一聯(lián)系確認(rèn)版權(quán)者。如涉及作品內(nèi)容、版權(quán)和其它問題,請(qǐng)及時(shí)通過電子郵件或電話通知我們,以便迅速采取適當(dāng)措施,避免給雙方造成不必要的經(jīng)濟(jì)損失。聯(lián)系電話:010-82306118;郵箱:aet@chinaaet.com。