Go Down

Topic: Arduino Mini and I2C TWI issues (Read 1 time) previous topic - next topic


Nov 28, 2006, 03:21 pm Last Edit: Nov 28, 2006, 03:24 pm by landon Reason: 1
On my Arduino Mini, when I do a Wire.begin(), the arduino seems to hang.  I have an LCD attached and am print line debugging.  I never get to a debug statement after the Wire.begin().

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.

Code: [Select]
#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

void setup( void )
 digitalWrite(13, HIGH);  // turn on debug LED  


 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:

Code: [Select]
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);
   // activate internal pull-ups for twi
   // as per note from atmega128 manual pg204
   sbi(PORTD, 0);
   sbi(PORTD, 1);

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 on the mini like they are on the bigger arduino board.  I soldered a small female breakaway header to the ADC4 and ADC5 ports so I could access them.  The solder connections are good and no bridges can be seen under a magnifier.

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?

Go Up