5
\$\begingroup\$

I want to build an RTC clock for the Raspberry Pi. Adafruit has a guide to accomplish this with Dallas DS1307. On the schematic they put a 2.2K resistor between VCC and SCL and do the same for VCC and SDA. SQLW is just wired out. But on the IC's datasheet, the resistors are proposed to be elsewhere:

Serial Data Input/Output. SDA is the data input/output for the I2C serial interface. The SDA pin is open drain and requires an external pullup resistor. The pullup voltage can be up to 5.5V regardless of the voltage on VCC.

Square Wave/Output Driver. When enabled, the SQWE bit set to 1, the SQW/OUT pin outputs one of four square-wave frequencies (1Hz, 4kHz, 8kHz, 32kHz). The SQW/OUT pin is open drain and requires an external pullup resistor. SQW/OUT operates with either VCC or VBAT applied. The pullup voltage can be up to 5.5V regardless of the voltage on VCC. If not used, this pin can be left floating.

So the question is: why there is a resistor at SCL and why there isn't any at SQW?

\$\endgroup\$

3 Answers 3

1
\$\begingroup\$

Seems like just a line omission from the datasheet. On the Pin Description section of Page 6

Pin 5- SDA:

Serial Data Input/Output. SDA is the data input/output for the I2C serial interface. The SDA pin is open drain and requires an external pullup resistor. The pullup voltage can be up to 5.5V regardless of the voltage on VCC.

Pin 6- SCL:

Serial Clock Input. SCL is the clock input for the I2C interface and is used to synchronize data movement on the serial interface. The pullup voltage can be up to 5.5V regardless of the voltage on VCC.

It seems to just skip a line stating that the pin is open drain and requires the external pull up, but then adds the same line afterwards, stating the pull up value. Looking at older versions of the datasheet, back when Maxim Integrated was Maxim-Dallas and even just Dallas Semi, the omission has always been there.

That said, the typical wiring diagram has always been correct, showing the pull up needed on both i2c lines, as the i2c standard requires.

As for the SQW/Out pin, the Pull Up is only required if you are using the line. It can be disabled in the rtc's settings (Or should I say, comes disabled, needs to be turned on). Having a pull up resistor on the line, when you are not going to use it, will waste energy, needlessly draining a battery (Slowly) in battery applications. As the datasheet says, this can be left floating, i.e. no pull up, if not needed. The Adafruit device breaks it out for your convenience if you do want to use it, but you need to add the pull up externally if you want to (or use the Arduino's internal pull-up option)

\$\endgroup\$
6
\$\begingroup\$

Those resistors on SDA and SCL are I2C pullups. In order to work I2C bus needs proper pullups. This is because the IOs on the bus are open drain.

Here is an excerpt from i2c-bus.org:

The I2C bus transmits data and clock with SDA and SCL. First thing to realize: SDA and SCL are open-drain (also known as open-collector in the TTL world), that is I2C master and slave devices can only drive these lines low or leave them open. The termination resistor Rp pulls the line up to Vcc if no I2C device is pulling it down. This allows for features like concurrent operation of more than one I2C master (if they are multi-master capable) or stretching (slaves can slow down communication by holding down SCL).

Best place that explains SQW out is the datasheet. In the ref design below, the pullup is there on the SDA, SCL and SQW out.

enter image description here
Following is the block diagram depicting the SQW output stage.

enter image description here

Also see the description of the SQW pin mentioning the requirement of a pullup resistor.

enter image description here

\$\endgroup\$
3
\$\begingroup\$

Both of these outputs are open drain - meaning, they need a pull up to be red properly. Adafruit probably just have made the board be used as an I2C device and it's up to you to pull SQW/OUT up if you are going to use it.

On another note - you can enable internal pullup for you microcontroller pin you are using to read SQW/OUT signal.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.