I'm using Mac OSX and I don't get the problem when I include Wire.h.
I am using an Arduino Ministamp, though, so that might be a difference.
However, when I do a Wire.begin(), it hangs.
I have pull-ups on the I2c bus (I'm using 10K's...not sure what values to use with the Arduino Mini). It hangs with or without pullups.
Also, I started reading the wire code and am concerned that it may not work at all with the Mini. Has anyone got I2c working with the Mini?
I have a working LCD on my setup and use it for debug. I'm trying to set up to talk to the Sparkfun real time clock device on I2C.
#include <stdio.h>
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd = LiquidCrystal();
int loopct = 0;
// based on SFE Pic code, the RT device address is 0xD0
#define RT_DEVICE_ADDRESS 0xD0
void setup( void )
{
lcd.init();
digitalWrite(13, HIGH); // turn on debug LED
lcd.printIn("Wire.begin()");
Wire.begin();
lcd.clear();
lcd.printIn("Wire init done");
}
In the case above, I see "Wire.begin()" but it never displays "Wire init done". It seems to hang in the Wire.begin().
So, I started looking through the wire and twi code. One of the things that concerns me is this:
void twi_init(void)
{
// initialize state
twi_state = TWI_READY;
#ifdef ATMEGA8
// activate internal pull-ups for twi
// as per note from atmega8 manual pg167
sbi(PORTC, 4);
sbi(PORTC, 5);
#else
// activate internal pull-ups for twi
// as per note from atmega128 manual pg204
sbi(PORTD, 0);
sbi(PORTD, 1);
#endif
From what I can tell the internal pull-ups on an Atmega168 (arduino mini) is on PORTB. Given the comments in the code re: Atmega128 and this is the default if it's not an Atmega8, it makes me think the Wire interface has not yet been ported to work with the Mini.
I've put a scope on the Arduino mini ADC4 and ADC5 ports and never see any activity with Wire.begin(). These ports are not pinned out - I soldered a small female breakaway header to the ADC4 and ADC5 ports so I could access them.
Again, I have doubts that the Wire library and the Mini are currently compatible. Has anyone else researched this or succeeded with the I2C/TWI interface on the Mini?
But back to the thread - I can include Wire.h without a hang, but it is potentially because I'm using a Mini and Wire is hosed for an Arduino Mini (I suspect.)