I started in on it again tonight and breadboarded the Arduino mini with the Arduino USB->Serial converter. I then wired up the Sparkfun Real Time Clock. I had previously soldered a two-hole female header to the ADC4/ADC5 pins on the mini and ran the RTC SDA line to ADC4 and RTC SCL to ADC5 of the mini. Of course I powered the clock as well.
I ported some code by combining Julian's page and some of the PIC code that came with the RTC (I used that only for addresses, register numbers, and basic info on the RTC.)
The problem I'm having is identical to what I've seen before when I tried to do this and that is that the chip hangs in the Wire.begin().
In the case, tonight, I put a serial print before Wire.begin and one after. From the console, I only get to the one before.... I see "Calling Wire.begin", but not the print after Wire.begin.
Also of note, every few seconds, setup() gets called again - the chip must be going through a reset and I see my serial print before the Wire.begin.
I tried it with the clock disconnected from the ADC4/ADC5 lines. Same results.
I'm nearly 99% certain Wire is boned on an Arduino Mini.
You can pretty much ignore all the code I've written so far, though I'm posting it below, because it doesn't ever get past the Wire.begin call from what I can tell.
Code: Select all
// Landon Cox
// TWI (I2C) sketch to communicate with the Sparkfun RTC
// code loosely based on Julian's TWI page:
// and SparkFun's PIC code to get register and address values
#define RTCADDRESS 0x00
//Read hours register
#define RDHR 2
//Read minutes register
#define RDMIN 1
//Read seconds register
#define RDSEC 0
#define RDDAY 3
#define RDDATE 4
#define RDMON 5
#define RDYR 6
Wire.begin(); // join i2c bus (address optional for master)
Serial.println("Back from Wire.begin");
int hours=0, minutes=0, seconds=0;
hours = readregister(RDHR);
minutes = readregister(RDMIN);
seconds = readregister(RDSEC);
sprintf(timestr,"time %d:%d:%d\n", hours, minutes, seconds );
int readregister(byte registernum)
byte value_l=0, value_h=0;
// Now do a transfer read
value_l = Wire.receive();
value = value_h << 8 | value_l;