RTC MCP7940N calibration
I getting trouble in RTC time. My RTC is daily routine 2 to 4 second lost(Lagging) with reference clock. My RTC part is MCP7940N.So i calibrate this time but i facing the problem with calibration.
My calibration is 24 hrs monitoring and 6 second lagging. After the calibration of this my RTC gained(Leading) the 2 to 3 second.
this is my codding...
I used the equation given in data sheet. I cant find what i am doing wrong....
ppm = data; // this data is lost the second in 24 hrs.
ppm = ppm * 5.7870370; // 1000000 / 172800.0 --- 172800.0 Sec = 48 Hrs
ppm = (ppm * 0.98304); // 32768*60/1000000*2 = 0.98304
variable.rtc_present_data = ppm + 0.5; //0.5 =rounf off
" variable.rtc_present_data " is the calibration register of RTC. In this register MSB bit will be 0 or 1, Its depend on your RTC which is second gained or lost. if it is lost then it must be set 1.