Hi,
I am making a quadcopter with an Arduino Mega 1280 and the sensors ITG3200, ADXL345, LSM303 and BMP085. All of these use I2C protocol.
The problems came when I turn on the brushless motors and my Arduino was freeze. In this post I found the solution for this:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1283887406
But some days ago, when I tried to use all of my sensors, my arduino restart. Researching this problem, I could see that my free SRAM was reducing and after some days debugging all of my code I could see that the problem came from the solution previous.
Every time that the timeout is true, the i2c is restarted. In the twi_init() we allocate the buffers again and the SRAM is reduced every time.
I attach the simple modification which solve this situation.
I hope that it will help you and sorry for my english ![]()
twi.c (14.9 KB)
twi.h (1.63 KB)