I²C with ATTiny85 at 8MHz using TinyWireM library Hello fellow Arduino enthusiasts, I am trying to make the ATTiny85 talk I²C with a MMA7660 breakout board I have (it's an accelerometer, this is a follow up question to my previous one). 

I would state in advance that the I²C chip works perfectly with Arduino Nano, that I am using the Arduino IDE v1.5.6-r2, using the arduino-tiny core (from here) and that until now I had no special issues working at 8MHz.

The official documentation for the TinyWireM library (at the Arduino playground website) states that:


  By default the I2C master library (TinyWireM) is set to run at 1MHz.
  To run at 8MHz, #defines in USI_TWI_Master.h / .cpp must be changed.


I have made the following changes in USI_TWI_Master.cpp:

#define F_CPU 8000000UL // was 1000000UL


I have made the following changes in USI_TWI_Master.h:

#define SYS_CLK   8000.0 // was 1000.0
#define T2_TWI    1.3 // was 5 
#define T4_TWI    0.6 // was 4 


My guess is that the T2_TWI &amp; the T4_TWI values are wrong. I also tried T2_TWI 40 and T4_TWI 32 (as stated here), and T2_TWI 2 &amp; T4_TWI 1 (as stated here) but no luck. I also tried some other values in between that I thought might make sense but it won't work.

The code I am running is the I²C scanner from here (which as I mentioned works perfectly with the Nano and finds the device), the blow is a modified version for interfacing the TinyWireM library instead of the Wire library:

#include &lt;TinyWireM.h&gt;
#include &lt;SoftwareSerial.h&gt;

SoftwareSerial mySerial(-1,4);

void setup()
{
  TinyWireM.begin();
  mySerial.begin(9600);
  mySerial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address;
  int nDevices;
  mySerial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address &lt; 127; address++ ) 
  {
    TinyWireM.beginTransmission(address);
    error = TinyWireM.endTransmission();

    if (error == 0)
    {
      mySerial.print("I2C device found at address 0x");
      if (address&lt;16) 
        mySerial.print("0");
      mySerial.print(address,HEX);
      mySerial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      mySerial.print("Unknow error at address 0x");
      if (address&lt;16) 
        mySerial.print("0");
      mySerial.println(address,HEX);
    }  
  }
  if (nDevices == 0)
    mySerial.println("No I2C devices found\n");
  else
    mySerial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}


As a side note I would say that my logic analyzer was broken recently and I'm sure it would have helped here... Also I am aware of the sound-card hack to be used as logic analyzer, but would prefer to avoid adding more error-prone variables to the system, if possible, for now. 

Here is a picture of probing with Saleae logic analyzer of the two channels. The result of the code above is "No I2C devices found":



(Full size picture)

Would appreciate the insights of anyone with experience using ATTiny85 at 8Mhz with I²C successfully.
You really just need to scope the signals, even if it's with a DSO Nano-type scope.

Without downloading the datasheets:


I would guess your pull-up is probably too small, but possibly too large (scope it)
Slew rate may be either insufficient or too steep (scope it)
Be aware that the ATTiny runs at "8MHz", and not 8.00MHz. The timing error can be off enough to cause communication issues at high speeds while working well at lower speeds (scope it, and/or start at default and incrementally increase speed by 0.5MHz until it stops working)
MMA may not support a typical protocol feature being used, i.e. 'repeated start', burst transfers, etc. (datasheet register/programming section)


Edit: Both the ATTiny and the MMA should have bypass capacitors near the power pins.