Real-Time Clock (RTC)
An RTC maintains time and, where provided, calendar registers for another circuit to read. Backup operation, alarms, interface availability and crystal arrangements depend on the device. The DS3231 is one example with an integrated crystal, temperature compensation, I²C and automatic backup-supply switching.
An oscillator provides a reference that the timekeeping circuit divides and counts. The DS3231 uses a nominal 32.768 kHz reference, reads temperature and adjusts a capacitor array to compensate crystal-frequency drift. Its specified frequency stability is ±2 ppm from 0°C to +40°C and ±3.5 ppm over the wider specified industrial temperature range, under the datasheet conditions. This is not a promise that every RTC or every complete system holds the same accuracy.
In plain terms
A small clock beside the main computer. It can keep counting while the computer sleeps, provided the clock still has the power and oscillator conditions it needs.
Also called: real time clock, DS3231, DS1307, PCF8523.
Why designers use it
- Keeping a local date/time through main-power interruptions with suitable backup power.
- Providing supported alarm or square-wave functions.
- Time-stamping events without requiring the main processor to count continuously.
Best for
- Dataloggers and sensor nodes
- Alarm clocks and timers
- Scheduled wake-up tasks
- Time-stamped event recorders
- Battery-powered IoT devices
Key specifications
- DS3231 temperature stability: ±2 ppm at 0°C to +40°C; ±3.5 ppm across -40°C to +85°C under stated conditions
- Backup operation: Supply limits, current, oscillator and interface behaviour are device-specific
- Time validity: Check status flags, calendar range and initialization
- Error budget: Include temperature, supply effects, aging and synchronization needs
When not to use it
- When an existing system clock already meets retention, accuracy and power requirements.
- As a substitute for a synchronized time reference when the application requires synchronization beyond the RTC's drift budget.
Common mistakes
- Assuming the communication interface remains accessible in every backup-power state.
- Using a rechargeable-cell charging circuit with a non-rechargeable battery.
- Ignoring oscillator-stop or power-loss status when deciding whether stored time is valid.
- Applying one device's supply, century handling or alarm behaviour to all RTCs.
- Treating a temperature-stability figure as a complete lifetime error budget.
Where you will find it
- A battery-backed logger can read an RTC after restarting, check its validity flags and attach a time to new measurements.
- A DS3231-based design can use its two programmable time-of-day alarms, with interrupt configuration and backup-state behaviour checked in the datasheet.
A short history
RTC designs combine an oscillator, counters, calendar logic and, in suitable devices, backup-power management. The DS3231 integrates a temperature-compensated crystal oscillator and an aging-trim register. It illustrates one approach to improving a local clock's stability without implying that all RTC families use the same compensation mechanism.
Good to know
- 32,768 is 2¹⁵, so fifteen divide-by-two stages reduce that nominal frequency to 1 Hz.
- The DS3231's temperature compensation adjusts its crystal load rather than simply assuming the crystal never drifts.