Main Site Documentation

RTC Battery Issue


#1

Hi All, I’m working on a project using FEZ Rhino and I want to keep the date & time even with the power off, I’ve tried to connect a battery (CR2032) to V-BAT to board pin (battery positive to V-BAT pin and battery negative to GND pin).

At start of my main program I set up the time to RTC using RealTimeClock.SetTime( new DateTime(2010, 1, 1, 1, 1, 1)); and previously asking if the RTC datetime it’s a valid datetime (btw, function that the framework says that is obsolet)

Everything it’s working well when I have the FEZ Rhino board with power (USB or through 5V pin), but when I cut off the power, unpluging the USB cable or unpluging the 5v power source, the RTC don’t keep the date & time.

And isvalid function of the .NET micro framework it’s always returning me that the RTC time it’s invalid.

Could you please, give me some advice on this issue, because I’ve been loosing time on this since two weeks ago and my time frame to deliver it’s almost null.

I really appreciate your help and hope you can help me or give some code sample or advice of how to implement this.

Thanks in advance
Roberto.


#2

You set the RTC once. Then remove/comment out that line.
Then you have to set the runtime clock using the RTC datetime on startup.
Try that and let us know.


        private static DateTime SetDateTimeFromRTC()
        {
            //RealTimeClock.SetTime(...); // set once.
            DateTime dt = RealTimeClock.GetTime();
            Utility.SetLocalTime(dt);
            return dt;
        }


#3

The documentatio explains all thus with example code. Look at RealTimeClock class please


#4

Thanks guys, for your response, but I’m just doing that and I’m still getting a wrong behavior.

This is what is happening to me.

The RTC seems that is not running, because I’m getting always that time that I’ve seted up previously

I I set the Date Time to 04/14/2011 15:00:00, once I power off and power on my board again, the RTC it’s giving to me the previous set up time, it always it’s giving to me 04/14/2011 15:00:00. and the clock start to run from that time.

Should I missing some configuration or something that could be causing this behavior?

Thanks in advance
Roberto


#5

Do this


// set RTC
..........

while(true)
{
   Debug.Print(read RTC);
   Thread.Sleep(1000);
}

What do you see?


#6

If it’s not moving it could be the RTC xtal beeing damaged or not correctly soldered… ???
Besides the RTC, can you try to store something in BatteryRam and check if it’s still here after powercycling your device ?


#7

Gus, that what you told me works, but when i power off my board and power on it again, the RTC comeback to the initial seted time, seems that it is keeping the time but it’s not running.

Thx Nicolas3, for you advice, but I don’t think that could be a soldered issue, because this RTC it’s embed onto a FEZ Rhino board, from GHI, so I guess that won’t be manufacture issues.

Thank you so much to all for help me on this, any other thought?

Thx
Roberto


#8

Are you sure that you removed the the mothod that sets the RTC time and date off the code before resetting the device.


#9

yes show us the code…


#10

Why couldn’t nxp make the rtc and system clock the same thing on chip? Then power rtc (or not) from vbat. If vbat on, the system clock just keeps ticking. If no vbat, acts same as today when power goes off.


#11

Hi Guys, thank you so much for all your help.

Now it’s working OK, seems that was an issue related with the battery socket I’ve changed it and it is working good now.

I really appreciate all your help, thank you so much.

Thanks
Roberto


#12

Roberto, Nice that it’s fixed. I had a similar problem on my Panda II but a different fix. You might find it of interest if you ever run across the same behavior. Here’s a link:
http://www.tinyclr.com/forum/2/2953/#/2/