I2C hang problem ? Freeze maybe from <twi>

Hi ..

I need your help !

I'm actually trying to pilot 20 led strip of 1 meter by PWM.

Maybe 0,15 mA for each one, drived by an IRF3205, with 4 atmega, linked by I2C. One atmega = 5 strip.

During my breadboard test, all was working, but with only 1 led (low current switched by mosfet = low noise)

The firs atmega is the master (brain) who is increasing PWM value of 20 variable when i push a button.

It's sending PWM value to the three slaves who are driving there led strip, and it's like that because i need 20 strip and one arduino can only drive 6.

So, with this configuration i think i have a problem with I2C, because sometimes, not at the same moment, I2C stop working (nothing sended, i see that at scope) and each atmega is freezing (led strip stay at the same value of PWM).

In a first time i was thinking that could be a EMC problem.
i had add shottky diode at each MOSFET, 100nf capacitor at each MOSFET, 100nf and 22pf capacitor near each atmega... 2,2k / 10k pull-up resistor for I2C bus... nothig happen, always the same issues.

During my google search i had read that there is some problem with actual wire library, in the twi.h, when it's lost in infinite while loop because one paquet is missing in count. And it's right, i'm sending a lot of value into I2C at each loop, like that :

//it's into loop :

  Wire.beginTransmission(10); // Envoyer vers device #16
  Wire.write(MLI_F); // Envoi
  Wire.write(MLI_G); // Envoi
  Wire.write(MLI_H); // Envoi
  Wire.write(MLI_I); // Envoi
  Wire.write(MLI_J); // Envoi
  Wire.endTransmission(); 

delay(1);
  
  Wire.beginTransmission(15); // Envoyer vers device #17
  Wire.write(MLI_K); // Envoi
  Wire.write(MLI_L); // Envoi
  Wire.write(MLI_M); // Envoi
  Wire.write(MLI_N); // Envoi
  Wire.write(MLI_O); // Envoi
  Wire.endTransmission(); 

delay(1);
  
  Wire.beginTransmission(20); // Envoyer vers device #18
  Wire.write(MLI_P); // Envoi
  Wire.write(MLI_Q); // Envoi
  Wire.write(MLI_R); // Envoi
  Wire.write(MLI_S); // Envoi
  Wire.write(MLI_T); // Envoi
  Wire.endTransmission(); 

  delay(1);

I had try I2C library, WSWire library... same issues. Anyone could help me to keep original wire library but maybe work on other idea/solutions ?

Thx a lot....

Post your code! And as the hardware might also be the cause of your problems: post a wiring diagram of your setup.

If you don't use Arduinos but custom ATmega boards, post schematics of these boards.