English
Time: August 3th, 2026
Browse: 493

A typical real-time clock uses a 32.768 kHz quartz crystal and an oscillator circuit to create a stable timing signal. This frequency is commonly used because it can be divided by 215, or 32,768, to produce one pulse per second. The RTCC block counts these pulses and continuously updates the seconds, minutes, hours, day, date, month, and year.

The RTC communicates with a microcontroller or processor through the I²C bus. The processor can use this connection to set the date and time, read the current time, or configure features such as alarms. When a programmed time is reached, the alarm circuit can generate an interrupt to wake the processor or activate another function. The RTC may also provide a selectable clock output between 1 Hz and 32 kHz.
During normal operation, the RTC receives power from the main VCC supply. If VCC is removed, the VBAT switchover circuit automatically connects the backup battery. This keeps the oscillator and timekeeping circuits running without powering the entire device. Some RTCs also include timestamp recording, SRAM, EEPROM, and identification memory, although these additional features are not available in every RTC.
A real-time clock circuit combines several parts to maintain the correct time and date. The exact design varies between RTC devices, but most circuits contain the following components.
The oscillator normally uses a 32.768 kHz quartz crystal to generate a stable timing signal. This frequency is useful because dividing it by 2^15, or 32,768, produces one pulse per second. Some RTC ICs include a built-in crystal or temperature-compensated oscillator for better accuracy.
The frequency divider reduces the 32.768 kHz oscillator signal to 1 Hz. This means the circuit produces one timing pulse every second. These pulses provide the basic reference used to update the clock and calendar.
These registers store the seconds, minutes, hours, day, date, month, and year. They update automatically as time passes. Many RTCs also account for different month lengths and leap years.
The power management circuit supplies the RTC from the main VCC source during normal operation. If the main power fails, it automatically switches to a backup battery or supercapacitor. This allows the RTC to continue counting time while the rest of the device is turned off.
An I²C or SPI interface connects the RTC to a microcontroller or processor. Through this connection, the system can set the initial time, read the current date and time, and configure available functions.
Many RTCs can generate an alarm or interrupt at a programmed time. This output may activate an event or wake a microcontroller from a low-power state. Some RTCs can also provide selectable clock outputs, such as 1 Hz or 32.768 kHz.
Some RTCs include SRAM, EEPROM, identification memory, or timestamp registers. These features can store small amounts of data, record when an event occurred, or capture the time of a power failure. They are useful additions but are not included in every RTC.

Based on system integration, RTC functions can be provided by an RTC built into a microcontroller, a separate RTC IC, or an integrated RTC module. As shown in the image, these configurations differ in their required components, PCB space, design effort, and timekeeping performance.
An internal RTC is built directly into a microcontroller, processor, or system-on-chip. In the first configuration shown, the MCU contains the RTC block but still uses an external 32.768 kHz crystal and oscillator components. This approach can reduce cost and component count. However, the crystal, load components, PCB layout, and oscillator settings must be carefully selected and tested because they directly affect accuracy and reliability.
An external RTC IC is a separate chip connected to the MCU through I²C, SPI, or another serial interface. In the second configuration, the RTC IC handles the clock and calendar functions but still requires an external 32.768 kHz crystal and related oscillator components. This configuration can provide independent timekeeping and additional functions such as alarms, battery switching, timestamps, calibration, or memory. However, its performance still depends on crystal selection and PCB design unless the crystal is integrated into the IC.
An RTC module combines the RTC circuit, crystal, and important oscillator components into one package or assembled unit. As shown in the third configuration, the MCU connects directly to the RTC module without requiring a separate crystal or external oscillator components. This simplifies PCB design, reduces component variation, and can improve timekeeping consistency. Some commercial breakout modules may also include a battery holder, resistors, capacitors, and connector pins, but these added parts are not required for a device to be classified as an integrated RTC module.
A standard crystal-based RTC uses an external or integrated 32.768 kHz quartz crystal as its timing source. It offers low power consumption and sufficient accuracy for general timekeeping. However, crystal tolerance, temperature, aging, load capacitance, and PCB layout can cause the clock to gain or lose time.
A temperature-compensated RTC uses a temperature sensor and correction circuit to reduce oscillator-frequency changes. It provides lower time drift across changing temperatures than a standard crystal RTC. The DS3231 is a common example with an integrated crystal and temperature-compensated crystal oscillator. This type is suitable for data logging, industrial equipment, outdoor systems, and other accuracy-sensitive applications.
A MEMS-based RTC uses a microscopic mechanical resonator instead of a quartz crystal. It can offer a compact design and strong resistance to shock and vibration. Its accuracy, temperature stability, current consumption, and cost depend on the specific device. The DS3231M is one example of an RTC with an integrated MEMS resonator.
RTC accuracy describes how closely the clock follows the correct time. It is commonly specified in parts per million (ppm). For example, an error of 1 ppm is approximately 0.0864 seconds per day, while 20 ppm can produce about 1.73 seconds of error per day. This small error accumulates over time, causing the RTC to run faster or slower. This gradual change is called clock drift.
RTC drift is affected by crystal tolerance, temperature, aging, supply-voltage changes, load capacitance, and PCB layout. Temperature is often a major factor because the frequency of a standard 32.768 kHz crystal changes as the surrounding temperature moves away from its optimal range. Temperature-compensated RTCs measure temperature and adjust the oscillator to reduce this error. For applications requiring long-term accuracy, the RTC should be tested under its expected operating conditions and periodically synchronized with a reliable source such as NTP or GPS.
An RTC normally operates from the main system supply. When that supply is removed, its power-switching circuit automatically changes to a backup source, such as a lithium coin cell, rechargeable battery, or supercapacitor. Only the low-power timekeeping section remains active during backup operation, allowing the RTC to preserve the time and date without powering the entire device.
RTC battery life depends on battery capacity, backup current, temperature, self-discharge, and leakage through the circuit board. It can be estimated by dividing battery capacity in milliamp-hours by RTC backup current in milliamps, but the actual life is normally shorter because batteries lose charge naturally and their performance changes with temperature and age. A low or failed backup battery may cause the RTC to reset, stop, or lose the correct time when the main power is disconnected. You must also ensure that a non-rechargeable coin cell is never connected to an RTC module that applies charging current.
|
Comparison
Factor |
RTC |
Microcontroller
Timer |
System
Clock |
NTP |
GPS
Time |
|
Main purpose |
Maintains calendar time and date |
Measures intervals and controls
timed events |
Provides operating-system time |
Synchronizes time through a
network |
Provides precise time from
satellites |
|
Calendar support |
Built-in date and time registers |
Not normally included |
Managed by the operating system |
Supplies reference time for the
system clock |
Supplies UTC-based reference time |
|
Operation during shutdown |
Continues with backup power |
Normally stops |
Stops when the system powers down |
Unavailable without an active
system and network |
Unavailable when the receiver is
off |
|
Typical accuracy |
Depends on the oscillator;
improved by compensation |
Depends on the microcontroller
clock source |
Depends on its clock source and
synchronization |
Generally high when the network
is stable |
Very high with a valid satellite
signal |
|
Timing resolution |
Commonly one second, although
some devices offer subsecond functions |
Microseconds or nanoseconds,
depending on hardware |
Often milliseconds, microseconds,
or finer |
Synchronization accuracy depends
on network delay |
Very precise with a
pulse-per-second output |
|
Long-term drift |
Accumulates unless calibrated or
synchronized |
Accumulates with clock-source
error |
Can accumulate but is often
corrected |
Regular synchronization reduces
drift |
Continuously corrected by
satellite timing |
|
Connectivity required |
No external connection after
setup |
None |
None for basic operation |
Requires a network and available
time server |
Requires an antenna and satellite
reception |
|
Startup availability |
Available immediately if backup
power was maintained |
Available when the controller
starts |
Available after system
initialization |
Available after establishing a
network connection |
Available after receiving and
processing satellite signals |
|
Power consumption |
Very low during backup operation |
Depends on clock frequency and
controller mode |
Requires the main system to
operate |
Requires the processor and
network interface |
Relatively high because the GPS
receiver must operate |
|
Hardware cost |
Requires an RTC circuit and
possibly a battery |
Normally built into the
microcontroller |
Included with the computing
system |
Low if network hardware is
already available |
Higher because it requires a GPS
receiver and antenna |
|
Main limitation |
Subject to oscillator drift and
backup-source failure |
Does not independently retain
calendar time |
Cannot run while the system is
fully powered off |
Depends on network availability
and delay |
Poor reception indoors and higher
power requirements |
|
Best use |
Offline clocks, timestamps, and
startup time |
PWM, delays, pulse counting, and
interval measurement |
Applications, logs, files, and
scheduled processes |
Networked computers, servers, and
IoT devices |
Telecommunications, scientific
systems, power grids, and remote synchronization |
|
RTC
IC |
Interface |
Oscillator |
Main
Features |
Important
Limitations |
|
DS1307 |
I²C |
External 32.768 kHz crystal |
Battery switchover, square-wave
output and 56-byte battery-backed RAM |
Requires a 5 V main supply;
accuracy depends strongly on the external crystal and layout |
|
DS3231 |
I²C |
Integrated crystal and TCXO |
High accuracy, two alarms,
temperature sensor, battery backup and programmable square-wave output |
Costs more and consumes more
backup current than many basic RTCs |
|
PCF8563 |
I²C |
External 32.768 kHz crystal |
Low power, alarm, timer, clock
output and low-voltage detector |
No dedicated automatic
battery-switchover input; accuracy depends on the crystal and circuit design |
|
PCF8523 |
I²C |
External 32.768 kHz crystal |
Low backup current, automatic
battery switchover, alarm, timer and digital offset adjustment |
Requires careful crystal
selection and calibration when better accuracy is needed |
|
MCP7940N |
I²C |
External 32.768 kHz crystal |
Battery switchover, alarms,
timestamps, digital calibration, SRAM and unique identification |
More registers and settings
increase software complexity |
|
MCP795W12 |
SPI |
External 32.768 kHz crystal |
EEPROM, battery-backed SRAM,
alarms, timestamps, watchdog timer and event detection |
Requires more pins than an I²C
RTC and has greater integration complexity |
• Determine the required accuracy: Check the RTC’s accuracy in parts per million (ppm) and calculate the expected daily or yearly drift. Use a temperature-compensated RTC when small time errors are important.
• Check the operating temperature range: Select an RTC that maintains acceptable accuracy across the temperatures the device will experience. Outdoor, automotive, and industrial equipment normally needs a wider temperature range.
• Compare power consumption: Review both normal operating current and backup current. Ultra-low-power RTCs are better for portable devices and systems that must run from a small battery for several years.
• Select an internal RTC, external IC, or module: An internal RTC reduces component count and cost. An external IC can offer better performance and more features, while a complete module simplifies prototyping and circuit design.
• Choose a compatible interface: Confirm whether the processor supports the RTC’s interface, such as I²C or SPI. I²C uses fewer signal lines, while SPI can provide faster communication but requires more pins.
• Verify the supply and logic voltage: Make sure the RTC’s main supply, backup supply, and interface voltage ranges are compatible with the microcontroller and the rest of the circuit.
• Check the backup-power design: Determine whether the RTC supports a coin cell, rechargeable battery, or supercapacitor. Check its switchover voltage, backup current, and charging circuit before selecting the backup source.
• Review the oscillator design: Decide whether to use an external crystal or an RTC with an integrated crystal, TCXO, or MEMS resonator. Integrated oscillators simplify PCB design, while an external crystal may reduce cost.
• Identify the required functions: Choose only the features the application needs, such as alarms, timestamps, countdown timers, watchdog timers, programmable clock outputs, calibration, or memory.
• Consider package size and PCB layout: Confirm that the package fits the available board space and can be assembled using the selected manufacturing process. External-crystal RTCs also require careful crystal placement and routing.
• Evaluate software support: Check the availability of drivers, libraries, example code, and documentation. Good software support can reduce development time and prevent errors in date, alarm, and power-management settings.
Most RTC modules communicate through I²C using four main connections: VCC, GND, SDA, and SCL. Some RTCs use SPI and require additional signal lines. Always confirm the module voltage, pinout, I²C address, and pull-up resistors before connecting it.

For an I²C RTC, connect VCC and GND to the appropriate Arduino power pins. Connect SDA to A4 and SCL to A5 on an Arduino Uno or Nano. On an Arduino Mega, SDA is pin 20 and SCL is pin 21. After wiring, install a library that supports the selected RTC, initialize the I²C bus, and upload a program to set and read the date and time. Check whether the RTC module already includes I²C pull-up resistors before adding external ones.

The Raspberry Pi uses 3.3 V I²C logic. Connect the RTC’s SDA line to GPIO2, physical pin 3, and SCL to GPIO3, physical pin 5. Connect ground to a GND pin and supply the module with a compatible voltage. Enable I²C in the Raspberry Pi settings, then use an I²C detection command to confirm the RTC address. Avoid modules that pull SDA and SCL up to 5 V because Raspberry Pi GPIO pins are not 5 V tolerant.

On many ESP32 development boards, the default I²C pins are GPIO21 for SDA and GPIO22 for SCL, although other pins can usually be assigned in software. Connect the RTC to a 3.3 V-compatible supply and ensure that the I²C pull-ups do not raise the signal lines above 3.3 V. Initialize I²C with the selected pins, detect the device address, and use a compatible RTC library to set or read the time.

Connect the RTC’s SDA and SCL lines to pins assigned to an STM32 I²C peripheral. The correct pins vary between STM32 models and board configurations, so check the device datasheet and alternate-function table. Configure the I²C peripheral using STM32CubeMX, the Hardware Abstraction Layer, or another supported framework. Confirm that the RTC and STM32 use compatible logic levels and that suitable pull-up resistors are installed.
• Computers and laptops use RTCs to maintain the system date and time when the main power is off.
• Data loggers use RTCs to add timestamps to temperature, pressure, humidity, and other measurements.
• Industrial equipment relies on RTCs to schedule operations and record faults, maintenance, and production events.
• RTCs allow IoT devices to perform scheduled tasks and retain time without an internet connection.
• Smart meters record energy consumption according to specific times and billing periods.
• Security systems use RTCs to timestamp alarms, access events, camera recordings, and sensor activity.
• Medical devices record the timing of measurements, treatments, reminders, and equipment events.
• Automotive systems use RTCs for dashboard clocks, event logs, charging schedules, and control functions.
• RTCs provide clock, alarm, timer, and scheduling functions in cameras, televisions, and household appliances.
• Communication equipment relies on RTCs for event logging, scheduled operation, and time synchronization.
• Point-of-sale systems add accurate dates and times to receipts, transactions, and audit records.
• Battery-powered devices use RTCs to maintain time in wearables, portable instruments, and remote sensors with minimal power consumption.
Storing UTC is generally better because it avoids problems caused by time zones and Daylight Saving Time changes. The system software can convert UTC into the correct local time when displaying it.
Most RTCs do not automatically manage Daylight Saving Time because the rules differ by country and can change. The microcontroller, operating system, or application software must normally make the adjustment.
Many RTCs automatically adjust for months with fewer than 31 days and calculate leap years within a specified date range. However, designers should check the datasheet because some devices may not correctly handle century exceptions such as the year 2100.
Binary-coded decimal stores each decimal digit separately, making clock values easier to display and interpret. However, the microcontroller may need to convert BCD values into standard binary numbers before performing calculations.
Many RTCs provide an oscillator-stop, voltage-low, or power-failure flag. Software should check this status during startup and request a new time setting or synchronization if the stored time cannot be trusted.
Some RTCs include digital calibration or aging-offset registers that allow small frequency corrections. The error should be measured over a suitable period and compared with a trusted reference before applying an adjustment.
CAP CER 7PF 50V C0G/NPO 0201
CAP CER 0.22UF 100V X7R 1206
CAP CER 2200PF 1.5KV X7R 1206
CAP CER 330PF 2KV NP0 1808
MOSFET N-CH 250V 51A TO220-3
IC CLOCK GENERATOR 16TSSOP
IC TRANSCEIVER FULL 2/2 16SOIC
DC DC CONVERTER 15V 100W
AC/DC CONVERTER 300V 95V 600W
VLSI QFP
CMX602BD CML
KOA TSSOP24
WJLXT971AC.A4-857342 INPHI


