Rs232 to I2C near to success!!!

Hi All!
I have a question about I2C library.

My hardware is this, an ARM7 CPU and two AtMega 8 all connected via I2C. :o
Both Atmega with diferent Id, and a function mix in this I2C lib to Get and Retreive data from the Rs-232 to I2C and viceversa.

here is my ugly code:

#include <Wire.h>

void setup()
{
Wire.begin(1);
Serial.begin(9600);
Serial.println(“Inicio”);

Wire.onRequest(requestEvent);
Wire.onReceive(receiveEvent);

}

void loop()
{
delay(20);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany){

char c = Wire.receive();
Serial.print(c);

while(1 < Wire.available()) // loop through all but the last
{
char c = Wire.receive();
Serial.print(c);
}}

void requestEvent()
{
Wire.send(“1234567890”);
}

Now on requestEvent the data is sent to the I2C, but the other part get data and print it only one time, but keeping send data onrequestevent.

So what event i must kill when i need print the data incomming to the AtMega from the ARM port?

It’s a HandShake problem!!! :stuck_out_tongue:

Ideas?

Best Regards
Frank

And goes more strange.... the ARM CPU saids all the time he send data to the slaves, ACK from Slave OK!!!

Best Regards Frank