Main Site Documentation

Rtc


#1

Hello,

I have made my own PCB with the ChipworkX module on it. I also added an battery for the RTC. I can set the time on my system, but everytime I reset the system I lose the RTC time. How can I solve this problem?

Kind Regards


#2

Can you give us the initialization code that you have to check if the RTC is already set?


#3

How did you set the time?

Like here? http://www.microframeworkprojects.com/index.php?title=Time_Services


#4

Hi,

This is code I am using:

[quote]owKey.WriteByte(0x66);
buffer = new byte[5];
owKey.Read(buffer, 0, 5);
byte[] BufSeconds = new byte[4];
BufSeconds[0] = buffer[1];
BufSeconds[1] = buffer[2];
BufSeconds[2] = buffer[3];
BufSeconds[3] = buffer[4];

                            int buttonTimeInSeconds = BitConverter.ToInt32(BufSeconds, 0);
                            DateTime TimeOnButton = new DateTime(1970, 01, 01, 12, 0, 0);
                            TimeOnButton = TimeOnButton.AddSeconds(buttonTimeInSeconds);
                            RealTimeClock.SetTime(TimeOnButton);
                            Utility.SetLocalTime(RealTimeClock.GetTime());[/quote]

With the OneWire interface I read the time from a Clock iButton. I don’t see the problem.

Kind Regards.


#5

Sorry, I do not understand! Have you looked at the page I linked you to? ChipworkX already has RTC built in so why are you using oneWire RTC?


#6

Where do you check if the RTC is initialized and set the date/time if not?

Take a look at this project:

http://www.fezzer.com/project/260/rtc-initialization-and-uptime-monitor/

It may help you to use the RTC.


#7

Hi,

It is an very easy system. I made 20 devices, all with an ChipworkX module. So at the first setup of one of the devices I need to set the time. So every time I put my Clock iButton on the OneWire I set the time to Now()!

But I have the following problem: If I reset the system the RTC goes to 1 January 2009. I don’t want to check the RTC if it’s initialized or set, I just want to set the RTC to my time. And don’t want to set every time I restart the system.


#8

Some people had similar issues. Usually related to mechanical problem (bad or wrong connection). There is a couple of threads on the forum. Here is one of them:

http://www.tinyclr.com/forum/10/1950/


#9

Please go back and read the code I linked to in the very first reply. You are setting the system time not the RTC. The link explain it all.


#10

Hi,

If I do the next:

I would set the RTC to the TimeOnButton and I would set the local time. This is the same as in the example. What am i doing wrong?


#11

To isolate problems, can you try RTC by itself? Just a small program that sets the clock…