⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ds12c887.txt

📁 这是用来读写DALLAS12C887的程序模块
💻 TXT
字号:
DS12C887测试程序22008-08-30 20:19时钟芯片DS12887驱动程序
 
Title: TestTM.c
Description: DS12887 testing programme
Author: xianyunsen
Problem Unresolved: the time is not sexagesimal


/************************************************/
/*Title: TestTM.c
/*Description: DS12887 testing programme
/*Author: xianyunsen
/*Problem Unresolved: the time is not sexagesimal
/************************************************/

#include <w77e58.h>
#include <absacc.h>

#define TM_second XBYTE[0x2000] //秒
#define AM_second XBYTE[0x2001] //秒闹
#define TM_minute XBYTE[0x2002] //分
#define AM_minute XBYTE[0x2003] //分闹
#define TM_hour   XBYTE[0x2004] //时
#define AM_hour   XBYTE[0x2005] //时闹
#define TM_week   XBYTE[0x2006] //周
#define TM_day    XBYTE[0x2007] //日(2位数)
#define TM_month XBYTE[0x2008] //月(2位数)
#define TM_year   XBYTE[0x2009] //年 (2位)

#define REG_a     XBYTE[0x200a] //寄存器A
#define REG_b     XBYTE[0x200b]
#define REG_c     XBYTE[0x200c]
#define REG_d     XBYTE[0x200d]
#define RAM_114   XBYTE[0x200e]
#define uchar unsigned char

unsigned char xdata time_buf[7];
sbit resetchip=p1^5;

void settime() //设置系统时间
{
       uchar xdata i;
       //unsigned int xdata x;
       //resetchip=0;
       //for(x=0;x<25400;x++);
       //resetchip=1;
       i=REG_d;
       REG_b=0xfa;
       TM_second =time_buf[0];
       TM_minute=time_buf[1];
       TM_hour=time_buf[2];
       TM_week=time_buf[3];
       TM_day=time_buf[4];
       TM_month=time_buf[5];
       TM_year=time_buf[6];
       REG_b=0x7a;
       i=REG_c;
}
   void readtime() //读取系统时间
   {
       uchar xdata a;
       do{ a=REG_a;} while((a&0x80)==0x80);
       time_buf[0]=TM_second;
       time_buf[1]=TM_minute;
       time_buf[2]=TM_hour;
       time_buf[3]=TM_week;
       time_buf[4]=TM_day;
       time_buf[5]=TM_month;
       time_buf[6]=TM_year;
   }
   void start12887(void) //启动时钟
   {
       uchar xdata i;
       unsigned int xdata x;
       resetchip=0;
       //for(x=0;x<1000;x++);
       resetchip=1;
       i=REG_d;
       REG_a=0x2f;
       REG_b=0xfa;
       AM_second=0;
       AM_minute=0xff;
       AM_hour=0xff;
       REG_b=0x7a;
       i=REG_c;
       //i=REG_d;
       //readtime();
   }
void main(void){
     uchar xdata i;
     EX1 = 0;
     start12887();
     time_buf[0]=9;
     time_buf[1]=75;
     time_buf[2]=9;
     time_buf[3]=2;
     time_buf[4]=11;
     time_buf[5]=1;
     time_buf[6]=05;
    // settime();
     for(;;){
          //i=REG_c;
          readtime();
     }
}
 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -