Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / System Validation and Replacement

The DS1307 jumps back 59 seconds on the hour. Is it the crystal or the read transaction?

A cabinet log occasionally shows 08:59:00 around the transition from 08:59 to 09:00, then returns to normal. A reference error of dozens of ppm normally accumulates over time. One entry mixing seconds, minutes and hours at a boundary calls for checking the data path. Multiple independent I²C transactions can collect fields from different snapshots. Acknowledgements do not establish that the combined time ever existed in the RTC.

START defines a snapshot

The DS1307 data sheet explains that calendar reads come from secondary buffers synchronized on any I²C START. The internal clock keeps running while those buffers are read. Suppose one transaction reads the hour and minute as 08:59, and after rollover a second transaction fetches seconds as 00. The assembled time 08:59:00 appears 59 seconds earlier than 08:59:59 even with a running crystal. A continuous read from 00h through 06h delivers the fields from one snapshot. If a write sets the pointer and a repeated START begins the read, use the actual read-phase START as the snapshot point. Check bus traffic. One function call does not necessarily mean one contiguous read.

At 100 kHz SCL, an address byte for the pointer write, the register pointer, an address byte for reading, and seven calendar bytes make ten groups of eight bits plus acknowledgement or termination. That is 90 SCL periods, or about 900 µs before other bus and software time. Even if the read spans the rollover, the snapshot stays coherent. The estimate concerns latency. Coherence follows from the transaction structure. If the log also needs RAM or other data, define which read phase supplies the time across firmware versions.

Writing seconds changes the next rollover boundary

Writing the seconds register resets the divider chain. Once the seconds byte is acknowledged, the data sheet requires the other time and date fields to be written within one second. Prepare the entire byte sequence before a continuous write. If a debugger pauses execution for 1.2 s halfway through, continuing the partial transaction is outside the specified timing. If an error or power transition interrupts the update, record which bytes were acknowledged, and read a new complete snapshot after recovery. Check whether CH leaves the oscillator running and interpret the calendar fields as BCD.

Use falling edges from the 1 Hz square wave to mark updates as described by ADI. Set 23:59:58 and compare old and continuous-read firmware around a minute rollover, midnight and a valid month transition. Save START positions, addresses and seven decoded bytes. Under bus load, deliberately add a delay between the old separate reads to expose field mixing. Keep the crystal and supply fixed to isolate the read-structure change.

Log host receipt time separately from the RTC snapshot. Receipt time can show bus and software latency but cannot replace the RTC seconds field. If multiple tasks use I²C, keep pointer selection through sequential read protected by the driver's bus ownership rules. Verify coherent boundary reads before evaluating long-term timekeeping. The crystal's environmental accuracy budget belongs to the latter test.

For field evidence, retain the original seven bytes and the start of their transaction before formatting the timestamp. If seconds and minutes are zero at midnight but the date is still yesterday's, establish whether the date came from the transaction or a host cache. An application that reads the date only once an hour can assemble a wrong day without any RTC fault. Document caching or use the complete snapshot for each full calendar record. Compare raw RTC values before inspecting network time correction or time-zone conversion.

References

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.