arduino and DS1307

OK I've been banging my head against this for the past two days.. I
can't seen to get my DS1307 to do anything. I have the circuit set up
like in the data sheet with a 32.768kHz 12.5pF crystal (http://
www.vishay.com/docs/35017/xt26t.pdf). I have pull-up resistors on the
SDA and SCL lines. I have tried this code:

#include "Wire.h"

#define RTC1307_CTRL_ID B1101000

void setup()
{
  Wire.begin();

  Serial.begin(9600);

  Wire.beginTransmission(RTC1307_CTRL_ID);

  Wire.send(0x00); // reset register pointer

  Wire.send(B00000000);

  Serial.print("It got this far");

  Wire.endTransmission();

  Serial.print("But failed to get here");

}

void loop()
{

  byte rtc_data[7];

  Wire.beginTransmission(RTC1307_CTRL_ID);

  Wire.send(0x00); // reset register pointer

  Wire.requestFrom(RTC1307_CTRL_ID, 7);

  for(int i=0; i<7; i++)
  {
    // store data in raw bcd format
    rtc_data[i]=Wire.receive();
  }

  for(int i=0; i<7; i++)
  {
    // print data in raw bcd format
    Serial.print(rtc_data[i]);
  }

}

It seems to get stuck on the " Wire.beginTransmission()" command. I
am guessing that that is the first command that the Wire Library is
counting on haveing the RTC acknowledge. If I comment out the
Wire.beginTransmission() line it will criuse along til it meets the
"Wire.requestFrom(RTC1307_CTRL_ID, 7);"

I have tried cutting and pasting other peoples' "working" code to see
if it is the code or the circuit but none of them work. I'll have to
wait to upload a picture but the circuit is pretty simple. I can't
imagine that is wrong unless 4.7kohm is too much for the pull-ups.

Any help would be appreciated,
John

I think that this is a hardware problem, as your code looks correct. I have a working DS1307 setup; but I'll have to dig it up to figure out what pull-up resistors it uses. That said, most applications seem to be using 4K7.

I think that this is a hardware problem, as your code looks correct. I have a working DS1307 setup; but I'll have to dig it up to figure out what pull-up resistors it uses. That said, most applications seem to be using 4K7.

That's what I thought too but I have gone over and over the schematic and the datasheet hoping I missed something. These are the connections I made.

DS 1307--------Arduino
1 & 2 --------> crystal 32.768kHz 12.5 pF
3 Vbat -------> Gnd connects to Arduino Gnd pin
4 Gnd -------> Gnd connects to Arduino Gnd pin
5 SDA -------> Arduino pin 4 and pullup to Vcc
6 SCL -------> Arduino pin 5 and pullup to Vcc
7 SQR -------> nothing right now but I have had it as a pullup to Vcc
8 Vcc --------> Arduino 5V

I have also tried it with a 0.1uF capacitor between Vcc and Gnd.

Thanks, John

John,
Your connection sounds OK. You seem to be addressing the chip correctly.
However, I think you may be accessing the chip too fast. Try putting a delay(1000) in Loop().

John,
Your connection sounds OK. You seem to be addressing the chip correctly.
However, I think you may be accessing the chip too fast. Try putting a delay(1000) in Loop().

Thanks! I'll give it a try tonight

John

Well. put several delays in just to see what would happen but nothing is happening. I tried to det up a DS1337 and got more of the same. I'm starting to wonder if it isn't the Arduino that is broken but it seems to work for quite a few other projects