Three questions about I2C

I am currently running a DS1307 and LCD controller. I am having issues with locking up randomly after hours of perfectly fine operation. I tested my 3V battery for the DS1307 and it tested fine.

Do I need “Wire.begin();” in my setup to run I2C? I am currently running without it.

Do I need pull-up resistors on SDA and SCL? Again, not running them right now.

What is the INT pin used for on these devices?

Thank you!!!

Do I need "Wire.begin();" in my setup to run I2C?

Yes.

Do I need pull-up resistors on SDA and SCL?

Yes. Around 5-10K works fine depending on the length of your SDA/SCL connections. Only have a single pull-up for each line, not at each device (unless you have a really long bus and then you have other considerations to worry about).

What is the INT pin used for on these devices?

You're probably referring the the Futurlec mini-board which has the pin confusingly named INT. It's really the square-wave output from the DS1307. You can configure the DS1307 to pulse the SQW pin at 1 second intervals. I suppose you could connect this to an digital input pin and tie an interrupt to it if you really need 1 second timing intervals.

Do I need pull-up resistors on SDA and SCL?

Maybe. I've never used them, as Wire.h enables the ATmega's internal pullups and I have found that to be sufficient.

I flew such a configuration with a DS1307 and two 24xx256 Flash ICs on the bus and it operated just fine down to about -40C. (OK, the 1307 didn't, but it was the commercial 0-85C version and it worked down to -20C anyway, then came back when it thawed.)

Having said that, I always put pads for a couple of pullups on my circuits, just in case...

-j

I've never used them, as Wire.h enables the ATmega's internal pullups and I have found that to be sufficient.

Have you looked at the I2C signals on a scope without a pull up? It might (and does) work but the signal shapes are total rubbish. You are trading in your noise margin for the sake of two resistors, it's just not worth it.

why does my program work without wire.begin(); ?

why does my program work without wire.begin(); ?

Apparently it doesn't as you're experiencing lock-ups after a while.

The primary reason for this is likely that you're corrupting either the stack or heap in RAM because the transmit and receive buffers are never getting allocated as this occurs during the begin() function.

void TwoWire::begin(void)
{
  // init buffer for reads
  rxBuffer = (uint8_t*) calloc(BUFFER_LENGTH, sizeof(uint8_t));
  rxBufferIndex = 0;
  rxBufferLength = 0;

  // init buffer for writes
  txBuffer = (uint8_t*) calloc(BUFFER_LENGTH, sizeof(uint8_t));
  txBufferIndex = 0;
  txBufferLength = 0;

  twi_init();
}

Besides, why does it matter whether or not it works? The library is designed to work a certain way and the begin() is required.