Application Note 504: Design Considerations For Dallas Real-Time Clocks
Application Note 504: Design Considerations For Dallas Real-Time Clocks
OVERVIEW
A real- time clock (RTC) allows a system to synchronize or time-stamp events to a time reference that can be easily understood by the user. Because RTCs are used in an increasing number of applications, designers should familiarize themselves with these RTCs to avoid design problems.
Selecting an Interface
RTCs are available in a wide range of bus interfaces. Serial interfaces include 2-wire, 3-wire, and Serial Peripheral Interface (SPI). Parallel interfaces include mux-bus (multiplexed data and address bus) and designs with separate address and bytewide data inputs. The choice of interface is often determined by the type of processor being used. Many processors include 2-wire or SPI interfaces. Others, such as 8051 processors and their derivatives support multiplexed address and data buses. Timekeeping NV RAMs use the same control signals as SRAMs, which many processors provide an easy interface to, and include battery-backed RAM in various densities. Finally, phantom clocks hide behind battery-backed RAM and use a 64-bit software protocol to gain access to the clock.
AN504
Module Packages
Timekeeping NV RAMs, mux-bus clocks, and some watchdog and phantom clocks are available in module and/or PowerCap packages. Modules include an embedded 32,768 Hz crystal and a lithium battery, making PCB design easier. However, crystals and batteries cannot tolerate the temperatures encountered during the reflow process. Modules may be attached manually or inserted in a socket after reflow. Modules may also be attached to the PCB using wavesolder, as long as the lithium battery is not exposed to temperatures above +85C. PowerCap products use a two-piece construction to provide a device that can be surface- mounted using the reflow process. The module base, containing the RAM and clock, is mounted to the board using standard reflow techniques. The PowerCap top, containing the heat sensitive battery and crystal, is snapped onto the base after soldering.
Clock Format
There are three major data formats used in RTCs: binary-coded decimal (BCD), binary with separate registers for the month, date, year, etc., and unformatted binary counters. The BCD format is the most common. One reason for its popularity is that the time and date can be easily displayed in a human-readable format with no conversion. Each 8-bit register represents two digits (one nibble per digit). Each 4-bit nibble can hold the binary representation of the digits 0 thru 9. An example of the register map for a typical BCD format clock is shown in Figure 1. Since some of bits are not needed for a particular time or date field, those bits can be used for special functions, general-purpose read/write bits, or can be hardwired to read back as always one or zero, depending upon the design. In Figure 1, bit 7 of the seconds register is used for the clock halt (CH) bit. The second format is the binary format, with separate registers like the BCD format. The binary format is normally a programmable option on some clocks with the BCD format The third format uses a single multibyte register representing the time in seconds in an unformatted binary value from some reference point.
PowerCap is a registered trademark of Dallas Semiconductor.
2 of 8
AN504
The time and date registers are updated once per second. The roll-over value for the date will vary depending upon the month and for February, by year. The day register, except for mux-bus clocks, is not tied to any other register. The day register will increment at midnight, and will roll over from 7 to 1. The programmer can select any particular day as 1, as long as the assignment is consistent throughout the program. On mux-bus clocks, Sunday must be 1 because the day register is used for the daylight savings test. The test for daylight savings is done at midnight on the preceding midnight roll-over, which must be accounted for when testing the daylight savings function. When changing from 12-hour mode to 24- hour mode, or from BCD to binary or binary to BCD, the time, date, and alarm registers must be re- initialized. Unformatted binary counter clocks have a single register, typically 32-bit, that is incremented once per second. Normally, a value of 00h in the register is considered to be some default time and date, e.g., the zero epoch value of 00:00:00 January 1, 1970 GMT. The binary value in the register then represents the elapsed time from that point. Software routines must be used to convert the 32-bit value to a readable time and date, and to convert user entries to a binary value.
Y2K Compliance
Dallas Semiconductor RTCs are either Y2K compliant, Y2K compatible, or do not contain date-sensitive logic. A Y2K-compliant clock has logic that includes century information (either century digits or a century bit) and correctly calculates the leap year through 2099. Y2K-compatible clocks correctly calculate the leap year through 2099, but requires the system software to track the century. Binary seconds clocks do not have date sensitive logic; the software must calculate the correct date, including leap year corrections.
3 of 8
AN504
Crystal Connections
All Dallas RTCs have internal bias networks. The crystal should be connected directly to the X1 and X2 pins, with no additional components (Figure 3). The crystal should be as close as possible to the X1 and X2 pins. A ground plane should be placed beneath the crystal, X1 and X2 (Figure 4). Digital signal lines should be routed away from the crystal and oscillator pins. Components that radiate significant levels of RFI should be shielded and located away from the crystal. Low-power crystal-oscillator circuits can be sensitive to nearby RFI, which can cause the clock to run fast.
4 of 8
AN504
PC boards containing tuning- fork crystals, such as those used with RTCs, should not be cleaned using ultrasonics. The crystal can be damaged by resonance vibration.
Battery Connections
Most Dallas RTCs include a battery input pin. The battery is intended to keep the RTC running while the main supply is off. For most of the designs, the battery is intended to be a lithium- type coin cell. Some RTCs use the battery voltage as a reference to determine when VCC is at a valid level. When VCC is below the minimum value, the part will go into write protect, locking out access to the part. While the RTC is operating from VCC, the VBAT input will be at a high impedance. If a battery is not connected to the VBAT input, or is connected with diodes in series, the VBAT input can float high, causing the RTC to go into write protect. Reverse charging protection is provided internally on most Dallas clocks, eliminating the need for external diodes. Check the following link for information about UL approval of the reverse charging protection: www.maxim- ic.com/TechSupport/QA/ntrl.htm.
5 of 8
AN504
6 of 8
AN504
AN504
Another source of negative voltages on the clock can come from RS232 connections. If the PCB with the clock IC is powered down, and a powered PC or other instrument is connected to that board via an RS232 connection, the RS232 transceiver IC(s) may pass the n egative marking voltage on to other ICs on the unpowered board. Inadvertent writes also cause data corruption problems. The processor can write incorrect data during power-up or power-down, before write protect switches in. The interface circuitry may force the input pins into a write condition upon power- up or power-down. In the case of mux-bus clocks, the address information is latched in on the falling edge of ALE. If /WE and /CS go low before the part is in write protect, the data in the last register that was last accessed will be corrupted. VCC rise and fall times should be verified that they meet the datasheet requirements. Intermittent data problems have been caused by interrupts routines that are not handled correctly. In some cases, the time and date information is copied to RAM, and the copies are not kept in sync. Finally, InCircuit Emulator (ICE) hardware can be configured improperly, causing erratic behavior.
Oscillator Problems
The most common reason for the clock to not increment is that the oscillator has not been enabled. Most Dallas clocks have a bit, usually located in the seconds register, that must be set before the oscillator will run. The oscillator circuit is designed to be low power, to prolong battery life. Problems with the crystal connection can decrease the loop gain, preventing the oscillator from running. External capacitors connected to the crystal will reduce the loop gain, and increase the start up time, or prevent oscillation. Oscilloscope probes can also prevent oscillation. Crystals with an ESR above 45k? will also decrease the loop gain. Finally, some water-wash solder fluxes can appear to leave the PCB clean, while leaving enough contaminates to prevent oscillation.
8 of 8