X1, X2 - 32.768kHz Crystal Connection
GND - Ground
SDA - Serial Data
SCL - Serial Clock
V
BACKUP
- Secondary Power Supply
SQW/ INT- Square-Wave/Interrupt Output
- Power Supply
APPLICATIONS
§ Handhelds (GPS, POS Terminal)
§ Consumer Electronics (Set-Top Box, Digital
Recording, Network Appliance)
§ Office Equipment (Fax/Printer, Copier)
§ Medical (Glucometer, Medicine Dispenser)
§ Telecommunications (Router, Switcher,
Server)
§ Other (Utility Meter, Vending Machine,
Thermostat, Modem)
Note: Some revisions of this device may incorporate deviations from published specifications known as errata. Multiple revisions of any device
may be simultaneously available through various sales channels. For information about device errata, click here: http://www.maxim-ic.com/errata.
1 of 18072302
Page 2
DS1339
DESCRIPTION
The DS1339 serial real-time clock is a low-power clock/date device with two programmable time-of-day
alarms and a programmable square-wave output. Address and data are transferred serially by a 2-wire
bidirectional bus. The clock/date provides seconds, minutes, hours, day, date, month, and year
information. The date at the end of the month is automatically adjusted for months with fewer than 31
days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with
AM/PM indicator. The DS1339 has a built-in power-sense circuit that detects power failures and
automatically switches to the backup supply.
OPERATION
The DS1339 operates as a slave device on the serial bus. Access is obtained by implementing a START
condition and providing a device identification code followed by data. Subsequent registers can be
accessed sequentially until a STOP condition is executed. The device is fully accessible and data can be
written and read when VCC is greater than VPF. However, when VCC falls below VPF, the internal clock
registers are blocked from any access. If VPF is less than V
to V
BACKUP
VCC to V
when VCC drops below VPF. If VPF is greater than V
BACKUP
when VCC drops below V
BACKUP
. The registers are maintained from the V
BACKUP
, the device power is switched from V
BACKUP
, the device power is switched from
BACKUP
CC
source
until VCC is returned to nominal levels. The block diagram in Figure 1 shows the main elements of the
serial real-time clock.
Figure 1.BLOCK DIAGRAM
X1X2
V
BACKUP
V
CC
SCL
SDA
OSCILLATOR
AND
DIVIDER
POWER
CONTROL
SERIAL BUS
INTERFACE
CONTROL
LOGIC
ADDRESS
REGISTER
TIMEKEEPING,
CONTROL,
AND
TRICKLE
CHARGE
REGISTERS
SQW
/
INT
2 of 18
Page 3
DS1339
SIGNAL DESCRIPTIONS
VCC, GND – DC power is provided to the device on these pins.
SCL (Serial Clock Input) – SCL is used to synchronize data movement on the serial interface.
SDA (Serial Data Input/Output) – SDA is the input/output pin for the 2-wire serial interface. The SDA
pin is an open-drain output and requires an external pullup resistor.
V
BACKUP
(Secondary Supply Input) – Connection for a secondary power supply. Supply voltage must
be held between 1.3V and 3.7V for proper operation. This pin can be connected to a primary cell such as
a lithium button cell. Additionally, this pin can be connected to a rechargeable cell or a super cap when
used with the trickle charge feature.
SQW/ INT (Square-Wave/Interrupt Output) – Programmable square-wave or interrupt-output signal.
The SQW/ INT pin is an open-drain output and requires an external pullup resistor.
X1, X2 – These signals are connections for a standard 32.768kHz quartz crystal. The internal oscillator
circuitry is designed for operation with a crystal having a specified load capacitance (CL) of 6pF.
For more information about crystal selection and crystal layout considerations, refer to Application Note58 “Crystal Considerations with Dallas Real-Time Clocks.”
The DS1339 can also be driven by an external 32.768kHz oscillator. In this configuration, the X1 pin is
connected to the external oscillator signal and the X2 pin is floated.
The oscillator is controlled by an enable bit in the control register. Oscillator startup times are highly
dependent upon crystal characteristics, PC board leakage, and layout. High ESR and excessive capacitive
loads are the major contributors to long startup times. A circuit using a crystal with the recommended
characteristics and proper layout usually starts within one second.
TYPICAL PC BOARD LAYOUT FOR CRYSTAL
3 of 18
Page 4
DS1339
CLOCK ACCURACY
The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match
between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was
trimmed. Additional error is added by crystal frequency drift caused by temperature shifts. External
circuit noise coupled into the oscillator circuit can result in the clock running fast. Refer to ApplicationNote 58 “Crystal Considerations with Dallas Real-Time Clocks” for detailed information.
ADDRESS MAP
The address map for the registers of the DS1339 is shown in Figure 2. During a multibyte access, when
the address pointer reaches the end of the register space (10h), it wraps around to location 00h. On a 2wire START, STOP, or address pointer incrementing to location 00h, the current time is transferred to a
second set of registers. The time information is read from these secondary registers, while the clock can
continue to run. This eliminates the need to re-read the registers in case of an update of the main registers
during a read.
4 of 18
Page 5
Figure 2. DS1339 TIMEKEEPER REGISTERS
ADDRESS BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 FUNCTION RANGE
00–23
03H 0 0 0 0 0 DAY Day 1–7
04H 0 0 10 DATE DATE Date 00–31
05H CENTURY 0 0 10 MO MONTH
Month/
Century
01–12 +
Century
06H 10 YEAR YEAR Year 00–99
07H A1M1 10 SECONDS SECONDS
08H A1M2 10 MINUTES MINUTES
AM/PM
09H A1M3 12/24
10HR HOUR
10HR
Alarm 1
Seconds
Alarm 1
Minutes
Alarm 1
Hours
00–59
00–59
1–12 +
AM/PM
00-23
Alarm 1
0AH A1M4 DY/DT 10 DATE
DAY
DATE
Day
Alarm 1
1–7
1–31
Date
0BH A2M2 10 MINUTES MINUTES
AM/PM
0CH A2M3 12/24
10HR HOUR
10HR
Alarm 2
Minutes
Alarm 2
Hours
00–59
1–12 +
AM/PM
00–23
Alarm 2
0DH A2M4 DY/DT 10 DATE
DAY
DATE
Day
Alarm 2
1–7
1–31
Date
DS1339
0EH
EOSC
0 BBSQI RS2 RS1 INTCN A2IE A1IE Control —
0FH OSF 0 0 0 0 0 A2F A1F Status —
10H TCS3 TCS2 TCS1 TCS0 DS1 DS0 ROUT1 ROUT0
Trickle
Charge
Note: Unless otherwise specified, the registers’ state are not defined when power is first applied or VCC and V
falls below the V
BACKUP
5 of 18
—
BACKUP
min.
Page 6
DS1339
TIME AND DATE OPERATION
The time and date information is obtained by reading the appropriate register bytes. The real-time clock
registers are illustrated in Figure 2. The time and date are set or initialized by writing the appropriate
register bytes. The contents of the time and date registers are in the binary coded decimal (BCD) format.
The DS1339 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours register is defined as the
12-hour or 24-hour mode-select bit. When high, the 12-hour mode is selected. In the 12-hour mode, bit 5
is the AM/PM bit with logic high being PM. In the 24-hour mode, bit 5 is the second 10-hour bit (20–23
hours). All hours values, including the alarms, must be re-entered whenever the 12/24-hour mode bit is
changed. The century bit (bit 7 of the month register) is toggled when the years register overflows from
99 to 00. The day-of-week register increments at midnight. Values that correspond to the day of week are
user-defined, but must be sequential (i.e., if 1 equals Sunday, then 2 equals Monday, and so on). Illogical
time and date entries result in undefined operation.
When reading or writing the time and date registers, secondary (user) buffers are used to prevent errors
when the internal registers update. When reading the time and date registers, the user buffers are
synchronized to the internal registers on any START or STOP, and when the address pointer rolls over to
0. The countdown chain is reset whenever the seconds register is written. Write transfers occur on the
acknowledge pulse from the device. To avoid rollover issues, once the countdown chain is reset, the
remaining time and date registers must be written within one second. The 1Hz square-wave output, if
enabled, transitions high 500ms after the seconds data transfer, provided the oscillator is already running.
ALARMS
The DS1339 contains two time-of-day/date alarms. Alarm 1 can be set by writing to registers 07h to 0Ah.
Alarm 2 can be set by writing to registers 0Bh to 0Dh. The alarms can be programmed (by the alarm
enable and INTCN bits of the control register) to activate the SQW/ INT output on an alarm match
condition. Bit 7 of each of the time-of-day/date alarm registers are mask bits (Figure 3). When all of the
mask bits for each alarm are logic 0, an alarm only occurs when the values in the timekeeping registers
00h–06h match the values stored in the time-of-day/date alarm registers. The alarms can also be
programmed to repeat every second, minute, hour, day, or date. Figure 3 shows the possible settings.
Configurations not listed in the table result in illogical operation.
The DY/DT bits (bit 6 of the alarm day/date registers) control whether the alarm value stored in bits 0 to
5 of that register reflects the day of the week or the date of the month. If DY/DT is written to a logic 0,
the alarm is the result of a match with date of the month. If DY/DT is written to a logic 1, the alarm is the
result of a match with day of the week.
When the RTC register values match alarm register settings, the corresponding alarm flag (A1F or A2F)
bit is set to logic 1. If the corresponding alarm interrupt enable (A1IE or A2IE) is also set to logic 1 and
the INTCN bit is set to logic 1, the alarm condition activates the SQW/
INT signal.
6 of 18
Page 7
Figure 3. ALARM MASK BITS
ALARM 1 REGISTER MASK BITS
DY/DT
A1M4A1M3A1M2A1M1
X1111Alarm once per second
X1110Alarm when seconds match
X1100Alarm when minutes and seconds match
X1000Alarm when hours, minutes, and seconds match
00000Alarm when date, hours, minutes, and seconds match
10000Alarm when day, hours, minutes, and seconds match
ALARM 2 REGISTER MASK BITS
DY/DT
A2M4A2M3A2M2
X111Alarm once per minute (00 second of every minute)
X110Alarm when minutes match
X100Alarm when hours and minutes match
0000Alarm when date, hours, and minutes match
1000Alarm when day, hours, and minutes match
(BIT 7)
(BIT 7)
ALARM RATE
ALARM RATE
DS1339
SPECIAL PURPOSE REGISTERS
The DS1339 has two additional registers (control and status) that control the RTC, alarms, and squarewave output.
CONTROL REGISTER (0Eh)
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
EOSC
EOSC (Enable Oscillator) – This bit when set to logic 0 starts the oscillator. When this bit is set to a
logic 1, the oscillator is stopped. This bit is enabled (logic 0) when power is first applied.
BBSQI (Battery-Backed Square-Wave and Interrupt Enable) – This bit when set to a logic 1 enables
the square-wave or interrupt output when V
pin. When BBSQI is a logic 0, the SQW/ INT pin goes high impedance when VCC falls below the powerfail trip point. This bit is disabled (logic 0) when power is first applied.
RS2 and RS1 (Rate Select) – These bits control the frequency of the square-wave output when the
square wave has been enabled. Figure 4 shows the square-wave frequencies that can be selected with the
RS bits. These bits are both set to logic 1 (32kHz) when power is first applied.
0BBSQIRS2RS1INTCNA2IEA1IE
is absent and the DS1339 is being powered by the V
CC
BACKUP
7 of 18
Page 8
Figure 4. SQUARE-WAVE OUTPUT FREQUENCY
RS2 RS1
SQUARE-WAVE OUTPUT
FREQUENCY
DS1339
0 0 1Hz
0 1 4.096kHz
1 0 8.192kHz
1 1 32.768kHz
INTCN (Interrupt Control) – This bit controls the relationship between the two alarms and the interrupt
output pins. When the INTCN bit is set to logic 1, a match between the timekeeping registers and the
Alarm 1 or Alarm 2 registers activate the SQW/INT pin (provided that the alarms are enabled).When the
INTCN bit is set to logic 0, a square wave is output on the SQW/ INT pin. This bit is set to logic 0 when
power is first applied.
A1IE (Alarm 1 Interrupt Enable) – When set to logic 1, this bit permits the A1F bit in the status
register to assert SQW/ INT (when INTCN = 1). When the A1IE bit is set to logic 0 or INTCN is set to
logic 0, the A1F bit does not initiate the an interrupt signal. The A1IE bit is disabled (logic 0) when
power is first applied.
A2IE (Alarm 2 Interrupt Enable) – When set to a logic 1, this bit permits the A2F bit in the status
register to assert SQW/ INT (when INTCN = 1). When the A2IE bit is set to logic 0 or INTCN is set to
logic 0, the A2F bit does not initiate an interrupt signal. The A2IE bit is disabled (logic 0) when power is
first applied.
STATUS REGISTER (0Fh)
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
OSF 0 0 0 0 0 A2F A1F
OSF (Oscillator Stop Flag) – A logic 1 in this bit indicates that the oscillator either is stopped or was
stopped for some period of time and can be used to judge the validity of the clock and date data. This bit
is edge-triggered and set to logic 1 anytime the oscillator stops. The following are examples of conditions
that can cause the OSF bit to be set:
1) The first time power is applied.
2) The voltage present on both VCC and V
BACKUP
3) The EOSC bit is turned off.
4) External influences on the crystal (e.g., noise, leakage, etc.).
This bit remains at logic 1 until written to logic 0. This bit can only be writte n to a logic 0. Attempting to
write to logic 1 leaves the value unchanged.
A1F (Alarm 1 Flag) – A logic 1 in the A1F bit indicates that the time matched the Alarm 1 registers. If
are insufficient to support oscillation.
the A1IE bit is a logic 1 and the INTCN bit is set to a logic 1, the SQW/ INT pin is also be asserted. A1F
8 of 18
Page 9
DS1339
is cleared when written to logic 0. This bit can only be written to logic 0. Attempting to write to logic 1
leaves the value unchanged.
A2F (Alarm 2 Flag) – A logic 1 in the A2F bit indicates that the time matched the Alarm 2 registers. If
the A2IE bit is a logic 1 and the INTCN bit is set to a logic 1, the SQW/ INT pin is also asserted. A2F is
cleared when written to logic 0. This bit can only be written to logic 0. Attempting to write to logic 1
leaves the value unchanged.
TRICKLE CHARGE REGISTER (10h)
The simplified schematic of Figure 6 shows the basic components of the trickle charger. The tricklecharge select (TCS) bits (bits 4–7) control the selection of the trickle charger. In order to prevent
accidental enabling, only a pattern on 1010 enables the trickle charger. All other patterns disable the
trickle charger. The trickle charger is disabled when power is first applied. The diode select (DS) bits
(bits 2 and 3) select whether or not a diode is connected between VCC and V
0, 1) select the value of the resistor connected between VCC and V
BACKUP
. Bit values are shown in Figure
BACKUP
. The ROUT bits (bits
5.
Figure 5. TRICKLE CHARGE REGISTER (10h) BIT VALUES
BIT 7BIT 6BIT 5BIT 4BIT 3BIT 2BIT 1BIT 0
TCS3TCS2TCS1TCS0DS1DS0ROUT1ROUT0
No diode, 250W resistor
One diode, 250W resistor
No diode, 2kW resistor
One diode, 2kW resistor
No diode, 4kW resistor
One diode, 4kW resistor
The user determines diode and resistor selection according to the maximum current desired for battery or
super cap charging. The maximum charging current can be calculated as illustrated in the following
example:
Assume that a system power supply of 3.3V is applied to V
and a super cap is connected to V
CC
BACKUP
Also assume that the trickle charger has been enabled with a diode and resistor R2 between VCC and
V
As the super cap or battery charges, the voltage drop between VCC and V
the charge current decreases.
9 of 18
BACKUP
decreases and, therefore,
Page 10
Figure 6. PROGRAMMABLE TRICKLE CHARGE
DS1339
V
CC
NOTE: ONLY 1010 ENABLES CHARGER
1 OF 16 SELECT
1 OF 2
SELECT
1 OF 3
SELECT
TCS3 TCS2 TCS1 TCS0 DS1 DS0 ROUT1 ROUT0
BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0
TRICKLE CHARGE REGISTER
R1
250W
R2
2kW
R3
4kW
TCS
= TRICKLE CHARGE SELECT
0-3
= DIODE SELECT
DS
0-1
ROUT
= RESISTOR SELECT
0-1
V
BACKUP
10 of 18
Page 11
DS1339
2-WIRE SERIAL DATA BUS
The DS1339 supports a bidirectional 2-wire bus and data transmission protocol. A device that sends data
onto the bus is defined as a transmitter and a device receiving data as a receiver. The device that controls
the message is called a master. The devices that are controlled by the master are referred to as slaves. The
bus must be controlled by a master device that generates the serial clock (SCL), controls the bus access,
and generates the START and STOP conditions. The DS1339 operates as a slave on the 2-wire bus.
Connections to the bus are made by the open-drain I/O lines SDA and SCL.
The following bus protocol has been defined (Figure 7):
§ Data transfer can be initiated only when the bus is not busy.
§ During data transfer, the data line must remain stable whenever the clock line is HIGH. Changes in
the data line while the clock line is HIGH are interpreted as control signals.
Accordingly, the following bus conditions have been defined:
Bus Not Busy: Both data and clock lines remain HIGH.
Start Data Transfer: A change in the state of the data line, from HIGH to LOW, while the clock is
HIGH, defines a START condition.
Stop Data Transfer: A change in the state of the data line, from LOW to HIGH, while the clock line is
HIGH, defines the STOP condition.
Data Valid: The state of the data line represents valid data when, after a START condition, the data line
is stable for the duration of the HIGH period of the clock signal. The data on the line must be changed
during the LOW period of the clock signal. There is one clock pulse per bit of data.
Each data transfer is initiated with a START condition and terminated with a STOP condition. The
number of data bytes transferred between START and STOP conditions is not limited and is determined
by the master device. The information is transferred byte-wise and each receiver acknowledges with a
ninth bit.
Acknowledge: Each receiving device, when addressed, is obliged to generate an acknowledge after the
reception of each byte. The master device must generate an extra clock pulse that is associated with this
acknowledge bit.
A device that acknowledges must pull down the SDA line during the acknowledge clock pulse in such a
way that the SDA line is stable LOW during the HIGH period of the acknowledge-related clock pulse. Of
course, setup and hold times must be taken into account. A master must signal an end of data to the slave
by not generating an acknowledge bit on the last byte that has been clocked out of the slave. In this case,
the slave must leave the data line HIGH to enable the master to generate the STOP condition.
11 of 18
Page 12
DS1339
Figure 7. DATA TRANSFER ON 2-WIRE SERIAL BUS
Depending upon the state of the R/ W bit, two types of data transfer are possible:
1) Data Transfer from a Master Transmitter to a Slave Receiver. The first byte transmitted by the
master is the slave address. Next follows a number of data bytes. The slave returns an acknowledge
bit after each received byte. Data is transferred with the most significant bit (MSB) first.
2) Data Transfer from a Slave Transmitter to a Master Receiver. The first byte (the slave address) is
transmitted by the master. The slave then returns an acknowledge bit. This is followed by the slave
transmitting a number of data bytes. The master returns an acknowledge bit after all received bytes
other than the last byte. At the end of the last received byte, a “not acknowledge” is returned. The
master device generates all of the serial clock pulses and the START and STOP conditions. A transfer
is ended with a STOP condition or with a repeated START condition. Since a repeated START
condition is also the beginning of the next serial transfer, the bus is not released. Data is transferred
with the MSB first.
12 of 18
Page 13
DS1339
The DS1339 can operate in the following two modes:
1) Slave Receiver Mode (Write Mode): Serial data and clock are received through SDA and SCL.
After each byte is received an acknowledge bit is transmitted. START and STOP conditions are
recognized as the beginning and end of a serial transfer. Address recognition is performed by
hardware after reception of the slave address and direction bit (Figure 8). The slave address byte is
the first byte received after the START condition is generated by the master. The slave address byte
contains the 7-bit DS1339 address, which is 1101000, followed by the direction bit (R/ W ), which, for
a write, is a 0. After receiving and decoding the slave address byte, the slave outputs an acknowledge
on the SDA line. After the DS1339 acknowledges the slave address + write bit, the master transmits a
register address to the DS1339. This sets the register pointer on the DS1339, with the DS1339
acknowledging the transfer. The master can then transmit zero or more bytes of data, with the
DS1339 acknowledging each byte received. The address pointer increments after each byte is
transferred. The master generates a STOP condition to terminate the data write.
2) Slave Transmitter Mode (Read Mode): The first byte is received and handled as in the slave
receiver mode. However, in this mode, the direction bit indicates that the transfer direction is
reversed. Serial data is transmitted on SDA by the DS1339 while the serial clock is input on SCL.
START and STOP conditions are recognized as the beginning and end of a serial transfer (Figure 9).
The slave address byte is the first byte received after the START condition is generated by the
master. The slave address byte contains the 7-bit DS1339 address, which is 1101000, followed by the
direction bit (R/ W ), which, for a read, is a 1. After receiving and decoding the slave address byte the
slave outputs an acknowledge on the SDA line. The DS1339 then begins to transmit data starting with
the register address pointed to by the register pointer. If the register pointer is not written to before the
initiation of a read mode, the first address that is read is the last one stored in the register pointer. The
address pointer is incremented after each byte is transferred. The DS1339 must receive a “not
acknowledge” to end a read.
Figure 8. DATA WRITE: SLAVE RECEIVER MODE
Figure 9. DATA READ: SLAVE TRANSMITTER MODE
13 of 18
Page 14
DS1339
ABSOLUTE MAXIMUM RATINGS*
Voltage Range on Any Pin Relative to Ground -0.3V to +6.0V
Operating Temperature Range-40°C to +85°C
Storage Temperature Range-55°C to +125°C
Soldering Temperature RangeSee IPC/JEDEC J-STD-020A
*This is a stress rating only and functional operation of the device at these or any other conditions beyond those indicated in the operation
sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods of time can affect reliability.
32.768kHz
Series ResistanceESR45k
Load CapacitanceC
*The crystal, traces, and crystal input pins should be isolated from RF generating signals. Refer to Application Note 58 “Crystal Considerations
for Dallas Real-Time Clocks” for additional specifications.
Warning: Under no circumstances are negative undershoots, of any amplitude, allowed when the device
is in backup-battery mode.
NOTES:
1) SCL only.
2) SDA, and SQW/INT .
3) I
4) Specified with 2-wire bus inactive, VIL = 0.0V, VIH = VCC, trickle charge disabled.
5) After this period, the first clock pulse is generated.
6) A device must internally provide a hold time of at least 300ns for the SDA signal (referred to the
7) The maximum t
8) CB: Total capacitance of one bus line in pF.
9) A fast-mode device can be used in a standard-mode system, but the requirement t
10) Using recommended crystal on X1 and X2.
11) The parameter t
12) Limits at -40°C are guaranteed by design and are not production tested.
13) This delay applies only if the oscillator is running. If the oscillator is disabled or stopped, no power-
: SCL at fSC max, VIL = 0.0V, VIH = VCC, trickle charge disabled.
CCA
V
of the SCL signal) in order to bridge the undefined region of the falling edge of SCL.
IHMIN
has only to be met if the device does not stretch the LOW period (t
HD:DAT
LOW
) of the
SCL signal.
³ to 250ns
SU:DAT
must then be met. This is automatically the case if the device does not stretch the LOW period of the
SCL signal. If such a device does stretch the LOW period of the SCL signal, it must output the next
data bit to the SDA line t
is the period of time the oscillator must be stopped in order for the OSF flag to be
OSF
RMAX + tSU:DAT
set over the voltage range of 0V V
= 1000 + 250 = 1250ns before the SCL line is released.
CC
V
and 1.3V V
CCMAX
BACKUP
3.7V.
up delay occurs.
18 of 18
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.