I am developing a data logger based on PIC controller. The PIC has internal RTC but does not have pins for connecting battery so I am using pic's internal RTC to generate interrupt every second and external battery backed RTC to keep exact timing. but the problem is that they both do not get in sync. So after every 5 second when I read time from external RTC it gives value 6 (or) 7. So how should I sync both RTC to get proper value from external RTC? We dont have pin from external RTC connected to MCU so cant get interrupt from external RTC.
actually I have solved the problem. What I have done is that whenever device starts I read date and time from external RTC and update the internal RTC with same so now I have to monitor only internal RTC which keeps all the timing requirement till the device turns off. again when device starts I again read from the external RTC. So this solves the problem of synchronization.
Forget the internal RTC. Configure an internal timer for a frequency 10 to 1000 Hz and check the external RTC on timer interrupt. Then only when you read a different external time, do your thing.