Working with a 6700 series interface board and initially updated the rtc from a web server. Reading it after the initial update gives me the correct time. Although, when I run some simple code again to check the time, all the same values remain.
Here is a subroutine from my code:
void getTime()
{
unsigned int curHour = rtc.tm_hour;
unsigned int curMin = rtc.tm_min;
printf("Hour: %d
", curHour);
printf("Min: %d
", curMin);
}
If I had just updated rtc using server at the moment (1:17), I would get:
Hour: 01
Min: 17
What am I forgetting to do here?
you should run the following 2 samples found in Samples\RTCLOCK
setrtckb.c
Example of setting the real-time clock from keyboard entry.
This program sets the Rabbit real-time clock from keyboard entry:
valid dates are from 1/1/1980 (entered as 1/1/80) to
12/31/2047 (entered as 12/31/47). Just press Enter
to leave the real-time clock unchanged.
and
rtc_test.c
Example of using the real-time clock functions by checking year 2000 rollover.
This program demonstrates the use of the RTC functions by:
- reading (and saving) the current date/time settings
- setting the date to 12/31/99 at 23:59:00
- reading the RTC again two seconds later
- setting the RTC back to the original date/time
What are you using to set the RTC?
You should use tm_wr() to write to the RTC. To read from the RTC you should use read_rtc(), not tm_rd().
tm_rd() reads from the macro SEC_TIMER which will not be updated until the power is reset.