欢迎来到天天文库
浏览记录
ID:50419684
大小:47.52 KB
页数:3页
时间:2020-03-09
《日历时钟DS12887或146818的C语言源程序.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、日历时钟DS12887或146818的C语言源程序#defineucharunsignedchar#defineuintunsignedint#include#include#include#include#include#include#include#defineP128870XBYTE[0xa000]#defineP128871XBYTE[0xa001]#defin
2、eP128872XBYTE[0xa002]#defineP128873XBYTE[0xa003]#defineP128874XBYTE[0xa004]#defineP128875XBYTE[0xa005]#defineP128876XBYTE[0xa006]#defineP128877XBYTE[0xa007]#defineP128878XBYTE[0xa008]#defineP128879XBYTE[0xa009]#defineP12887aXBYTE[0xa00a]#defineP12887bX
3、BYTE[0xa00b]#defineP12887cXBYTE[0xa00c]#defineP12887dXBYTE[0xa00d]#defineP12887eXBYTE[0xa00e]#defineP12887fXBYTE[0xa00f]voidsetup12887(uchar*p);voidread12887(uchar*p);voidstart12887(void);voidsetup12887(uchar*p)//设置系统时间{uchari;i=P12887d;P12887a=0x70;P1
4、2887b=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;}voidread12887(uchar*p)//读取系统时间{uchara;do{a=P12887a;}while((a&0x80)==0x80);
5、*p++=P128870;*p++=P128872;*p++=P128874;*p++=P128876;*p++=P128877;*p++=P128878;*p++=P128879;}voidstart12887(void)//启动时钟{uchari;i=P12887d;P12887a=0x70;P12887b=0xa2;P128871=0xff;P128873=0xff;P128875=0xff;P12887b=0x22;P12887a=0x20;i=P12887c;}这些地址,不要直接在代码中使
6、用,应该在前面用EQU/BIT等定义成某个顾名思义的字符串,(0字)坏蛋[11次]2004-1-422:30:09抄来的用的挺好!根据你的需要改改(16006字)gao_bc[18次]2004-1-510:51:21/*************************************************************文件名称:ds12c887.c适用范围:时钟芯片ds12c887的驱动程序*********************************************
7、****************/ #include/*命令常量定义*/#defineCMD_START_DS12C887 0x20 /*开启时钟芯片*/#defineCMD_START_OSCILLATOR0x70 /*开启振荡器,处于抑制状态*/#defineCMD_CLOSE_DS12C887 0x30 /*关掉时钟芯片*//*所有的置位使用或操作,清除使用与操作*/#defineMASK
8、_SETB_SET 0x80 /*禁止刷新*/#defineMASK_CLR_SET 0x7f /*使能刷新*/#defineMASK_SETB_DM 0x04 /*使用HEX格式*/#defineMASK_CLR_DM 0xfb /*使用BCD码格式*/#defineMASK_SETB_2412
此文档下载收益归作者所有