I2C strange problem

I am building a new quadcopter, using i2C ESCs this time. Also i use MPU-6050 which is also I2C. (the addresses are different, 52, 54, 56, 58 for the ESCs and 69 for the MPU)

The code for the ESCs to work is simply this: Wire.beginTransmission(0x52); Wire.write(FL); // Front Left, 0-255 Wire.endTransmission();

It works perfectly only if I [u]DON'T[/u] call wire.begin() but the MPU-6050 does not work if I do not call wire.begin()

I guess they work at different speeds or something. What is the default speed of Wire before i set it to 100KHz with Wire.begin() ? Also can i change the Wire speed whenever i want inside my code?

well i found it!

i2c speed is controlled by the TWBR register, TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;

Almost whatever speed i put in TWI_FREQ, it worked for the MPU-6050, but my ESCs were dead. So i printed the value of TWBR when i didn't call Wire.begin() and the value was (of course) =0!

And with a simple fix everything works:

i2c_speed=TWBR; TWBR = 0; Wire.beginTransmission(0x52); Wire.write(FL); Wire.endTransmission(); Wire.beginTransmission(0x58); Wire.write(FR); Wire.endTransmission(); Wire.beginTransmission(0x56); Wire.write(BL); Wire.endTransmission(); Wire.beginTransmission(0x54); Wire.write(BR); Wire.endTransmission(); TWBR = i2c_speed;

but i have no clue why it works...

Odd, with TWBR at 0 the interface should be running at about 1MHz. That sounds strange, i've never heard of it being used that fast and not sure if it would even operate at that speed. You could try setting the I2C freq to 1MHz and see if that works but I sense there are other forces at play there somewhere.