RTC Save and Restore

08 Feb 2011

I want to use the RTC registers to save data after reset or power up. I read everything in the forum I could find including the "Non-volitile Variable storage" topic. I need some guidance on how to store my variables and how to recall them on reset or powerup. In the "Non-volitile Variable storage" topic there are two Void functions; how would I call these to store and restore.

If I store my variable every time it changes to a RTC register such as:

LPC_RTC->GPREG0 = MOTOR_WATTHOURS

LPC_RTC->GPREG1 = FAN WATTHOURS

How would I recall the values from the register before the main() starts after a reset or powerup??

Thanks Bill Lynn

08 Feb 2011

You can read the values the same way you write them:

motor_wh = LPC_RTC->GPREG0;
fan_wh = LPC_RTC->GPREG1;

Just add some check for valid values to account for the initial run.

But why do you need them before main()?

09 Feb 2011

Really don't want them before main as you suggest; I really ment that I wanted them when main() starts.

Its working fine now; also had to add a watchdog timer. I'm using it for PACHUBE feeds on www.wjlengineering.com. Great product(mbed that is)!

Another question; is there a "easy"way to reset the RTC registers to zero.

09 Feb 2011

Well, how about just writing zeros into them?

09 Feb 2011

I already do that but it requires that I reload a new file into the mbed and after resetting the registers I have to load the regular file back in. I was wondering if there was an easier way????