Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Sun Nov 29, 2015 4:26 am |
|
|
Just call rtc_init, then read the time with rtc_get_date & rtc_get_time.
Provided the battery backup is correctly attached, the chip will have kept running. You'd ll need a way to call rtc_set_datetime, at some point when you _do_ want to adjust the date and time.
Look at the example ex_rtc.c
This does exactly this. You sit in a loop waiting for either 'S' (to set/change), or 'D' (to display the time). Wake it up, use 'S' to set the clock, then power the PIC down. Then re-power it, and use 'D'. You will see the clock still running counting from the value you set when you typed 'S'. |
|