打印

请教 DS12887

[复制链接]
2856|20
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
小明|  楼主 | 2007-7-8 14:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
各位大侠,请教一个关于12887的问题:
    我的程序读出来的时间和设置的时间一样,就是说它的时间没变化.比如:设置时间为 14:05:23  ,读出来的一直是 14:05:23  .是不是需要别的设置啊?
请问是什么原因?

相关帖子

沙发
hsw_21| | 2007-7-8 15:31 | 只看该作者

以前用过,好像当前时间有两种读出方式的。

使用特权

评论回复
板凳
小飞鼠| | 2007-7-8 15:43 | 只看该作者

re

看有没有启动计时!

使用特权

评论回复
地板
小明|  楼主 | 2007-7-8 16:22 | 只看该作者

怎么启动计时啊?

怎么启动计时啊?
我不知道 晕

使用特权

评论回复
5
NE5532| | 2007-7-8 16:33 | 只看该作者

看DATASHEET,有一个启动位要设置。

另外恭喜你买到新货。

使用特权

评论回复
6
小明|  楼主 | 2007-7-8 16:58 | 只看该作者

找不到啊

我看的是正文的说明书
里面的没提到启动的设置.
英文的 看得一知半解.没看明白.

使用特权

评论回复
7
gyt| | 2007-7-8 17:19 | 只看该作者

确实需要启动

我手里没有手册,帮不上忙:)

使用特权

评论回复
8
小明|  楼主 | 2007-7-8 17:23 | 只看该作者

一样谢谢你

同样感谢。

使用特权

评论回复
9
gyt| | 2007-7-8 17:40 | 只看该作者

不好意思

使用特权

评论回复
10
huangqi412| | 2007-7-8 17:48 | 只看该作者

对,看一下启动,还有确认软件没问题 只读秒看,看秒跳不,

使用特权

评论回复
11
小明|  楼主 | 2007-7-8 17:57 | 只看该作者

不行

就是读秒 不跳

使用特权

评论回复
12
NE5532| | 2007-7-8 19:43 | 只看该作者

哎,说了多少次,不要看中文。

OSCILLATOR CONTROL BITS
When the DS12887 is shipped from the factory, the internal oscillator is turned off. This feature prevents
the lithium energy cell from being used until it is installed in a system. A pattern of 010 in bits 4 through
6 of Register A turns the oscillator on and enables the countdown chain. A pattern of 11X turns the
oscillator on, but holds the countdown chain of the oscillator in reset. All other combinations of bits 4
through 6 keep the oscillator off.

使用特权

评论回复
13
小明|  楼主 | 2007-7-8 20:24 | 只看该作者

xie xie

thank you!!

使用特权

评论回复
14
小明|  楼主 | 2007-7-8 22:04 | 只看该作者

还是不行哦 郁闷

我已经按照上面讲的
把寄存器A 设定为 0X20 了还是不行啊
一样的现象 时间没有跳

使用特权

评论回复
15
古道热肠| | 2007-7-9 09:44 | 只看该作者

给个现成的给您,下不为例

//#define c_RTC_DS12C887_BasicAddr  XBYTE[0x4000]
#define c_RTCDS12C887BasicAddress 0x4000
#define DS12C887_M  XBYTE [c_RTCDS12C887BasicAddress + 0]//秒
#define DS12C887_MA XBYTE [c_RTCDS12C887BasicAddress + 1]//秒报警
#define DS12C887_F  XBYTE [c_RTCDS12C887BasicAddress + 2]//分
#define DS12C887_FA XBYTE [c_RTCDS12C887BasicAddress + 3]//分报警
#define DS12C887_S  XBYTE [c_RTCDS12C887BasicAddress + 4]//时
#define DS12C887_SA XBYTE [c_RTCDS12C887BasicAddress + 5]//时报警
#define DS12C887_X  XBYTE [c_RTCDS12C887BasicAddress + 6]//星期
#define DS12C887_R  XBYTE [c_RTCDS12C887BasicAddress + 7]//日
#define DS12C887_Y  XBYTE [c_RTCDS12C887BasicAddress + 8]//月
#define DS12C887_N  XBYTE [c_RTCDS12C887BasicAddress + 9]//年
#define DS12C887_A  XBYTE [c_RTCDS12C887BasicAddress + 0x0a]//寄存器A,A.7—只读判断忙闲
#define DS12C887_B  XBYTE [c_RTCDS12C887BasicAddress + 0x0b]//寄存器B,B.7—控制工作状态:0正常、1停止
                                  //         B.2—BCD码或二进制选择:0 二进制
                                  //         B.1—24/12小时模式选择:1 24小时进制
#define DS12C887_C  XBYTE [c_RTCDS12C887BasicAddress + 0x0c]//寄存器C
#define DS12C887_D  XBYTE [c_RTCDS12C887BasicAddress + 0x0d]//寄存器D  只读,读取该寄存器可使设置的时间和工作模式生效

bool TestRTCSRAM(void)
{
    uchar ucCount;
    bool bTestResult;
    uchar ucReadData;

    bTestResult = true;

    for(ucCount=14; ucCount<128; ucCount++)
    {
        XBYTE[c_RTCDS12C887BasicAddress+ucCount] = 0x5A;
        ucReadData = XBYTE[c_RTCDS12C887BasicAddress+ucCount];
        if(ucReadData != 0x5A)
        {
            bTestResult = false;
            break;
        }
    }
    
    for(ucCount=14; ucCount<128; ucCount++)
    {
        XBYTE[c_RTCDS12C887BasicAddress+ucCount] = 0xA5;
        ucReadData = XBYTE[c_RTCDS12C887BasicAddress+ucCount];
        if(ucReadData != 0xA5)
        {
            bTestResult = false;
            break;
        }
    }


    return(bTestResult);
}

/*
void InitRTCDS12C887(void)
{

}
*/
uchar year;
uchar month;
uchar day;
uchar hour;
uchar minute;
uchar second;

//--------------------------------------------//时钟判断忙闲
void clock_judge_busy(void)
{ while( DS12C887_A & 0x80 );//忙则循环等待
}

//--------------------------------------------//时钟读数据
void clock_read_data(void)
{
  clock_judge_busy();
  year = DS12C887_N;   //
  clock_judge_busy();
  month = DS12C887_Y;  //
  clock_judge_busy();
  day = DS12C887_R;    //
  clock_judge_busy();
  hour = DS12C887_S;   //
  clock_judge_busy();
  minute = DS12C887_F; //
  clock_judge_busy();
  second = DS12C887_M; //
}
//--------------------------------------------//时钟写数据
void clock_write_data(void)
{
    uchar i;

  DS12C887_B = 0x82;   //

  DS12C887_N = year;   //
  DS12C887_Y = month;  //
  DS12C887_R = day;    //
  DS12C887_S = hour;   //
  DS12C887_F = minute; //
  DS12C887_M = second; //

  DS12C887_A = 0x20;   //
  i= DS12C887_C;       //
  i= DS12C887_D;       //

  DS12C887_B = 0x02;   //
}

void TestRTCClock(void)
{
    year   = 0x07; //写入时间:2005年11月1日13时24分35秒(要设定的时间)
       month  = 0x07;
      day    = 0x04;
       hour   = 0x15;
       minute = 0x10;
       second = 0x00;
  //     clock_write_data();
        
    while(1)
    {
               clock_read_data();//读取的时间数据在变量year/month/day/hour/minute/second中
    }
}

void ReadRTCClock(uchar *ucReadString)
{
    clock_read_data();
    ucReadString[0] = 0x20;

    ucReadString[1] = year;
    ucReadString[2] = month;
    ucReadString[3] = day;

    ucReadString[4] = hour;
    ucReadString[5] = minute;
    ucReadString[6] = second;
}

使用特权

评论回复
16
小明|  楼主 | 2007-7-9 09:50 | 只看该作者

雪中送炭啊

好人啊! 真是人如其名!

使用特权

评论回复
17
gyt| | 2007-7-9 09:52 | 只看该作者

古版好好人啊:)

使用特权

评论回复
18
aduzzp| | 2007-8-24 15:01 | 只看该作者

have a try

void SetTime() 

    RegB = RegB | 0x80; /* 禁止刷新 */ 
    RegSecond=Second;        
    RegMinute=Minute;
    RegHour=Hour;
    RegDay=Day;    
    RegMonth=Month;         
    RegYear=Year;             
    RegB = RegB & 0x7f; /* 使能刷新 */ 
}

使用特权

评论回复
19
eda8888| | 2008-6-24 14:30 | 只看该作者

我的同样问题咋整都不行。

晕,没法子啊,我的还是不行。控制字改来改去了。程序写的应该没什么问题。想问下,不更新时间是怎么回事。

使用特权

评论回复
20
gszzjf| | 2010-4-2 13:16 | 只看该作者
终于看到了老好人:lol!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

11

帖子

0

粉丝