《电子技术应用》
您所在的位置:首页 > 嵌入式技术 > 解决方案 > 日历时钟DS12887或146818的C语言源程序

日历时钟DS12887或146818的C语言源程序

2009-01-16
关键词: 源程序 单片机

日历时钟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) //设置系统时间
{
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) //读取系统时间
{
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) //启动时钟
{
uchar i;
i=P12887d;
P12887a=0x70; P12887b=0xa2; P128871=0xff; P128873=0xff; P128875=0xff;
P12887b=0x22; P12887a=0x20;
i=P12887c;
}
 

本站内容除特别声明的原创文章之外,转载内容只为传递更多信息,并不代表本网站赞同其观点。转载的所有的文章、图片、音/视频文件等资料的版权归版权所有权人所有。本站采用的非本站原创文章及图片等内容无法一一联系确认版权者。如涉及作品内容、版权和其它问题,请及时通过电子邮件或电话通知我们,以便迅速采取适当措施,避免给双方造成不必要的经济损失。联系电话:010-82306118;邮箱:aet@chinaaet.com。