RTC DS1307 lagging problem

HI,
i am facing issue with RTC lag. Within 24 hours rtc gets lag by 1 hour. It is inaccurate. I am not using server connection to update it, but instead want to run RTC independently.

Sandip

Hi Sandip,
Are you using any readymade boards?
Check if your crystal is accurate enough and are using the right value capacitors.
There are trimming settings in the RTC. Look at them to correct the error.

no, it is our custom board.
capacitor is 0.1 pf & how can i check crystal accuracy???

trimming means prescalar value you are talking about???
do i have to generate alarm in rtc to get correct timing???

Refer datasheets for the right capacitance value and match the crystal capacitance value recommendation with the supporting capacitors.
Yes Prescaler values.
You can generate the clockout and see if your RTC supports that or you can use oscilloscope for checking the clock period.

if i use same firmware for the three same board then , lagging is different for each board i.e. 1hr, 20min & 10 min ahead of actual time. What does this mean??? Is crystal not accurate ??? i dont have DSO to measure frequency.

I am feeling your oscillator section is not tuned properly or shielded properly.
By tuning i mean either it can be,
Wrong capacitance value,
PCB layout rules not followed (Check for layout guidelines in the datasheet),
Crystal oscillator section is very near to noisy sources or your RTC power source is noisy.

Hi Ravi,

i have tested all above points with another application firmware for mentioned pcb board. RTC works accurate with other firmware. So i am sure it is with my firmware only but i dont know the reason yet. Is there anything that time RTC doesnt update its time while microcontroller is busy with other task