Hello Jorge,
I tried switching to SLAVE RX mode before changing anything on the I2Cx_S register, but SDA still locks up on Low. Here is the piece of code at the very beginning of the IIC ISR:
byte is;
byte ic;
is = I2C1_S;
ic = I2C1_C1;
if(is & 0x10) { // ARBL
arbl = TRUE;
I2C1_C1 &= 0xCF; // Switch to RX SLAVE before cleaning ARBL (errata e6749)
I2C1_S |= 0x10; // Clear ARBL
}
I2C1_S |= 0x02; // Clear IICIF
First, I save copies of I2C_C1 and I2C_S registers, and then I test for ARBL. If an arbitration loss has just occurred, I clear MST and TX bits on I2C_C1. Only after this, I clear the IICIF flag.
Unfortunately, it did not work. After receiving the slave ID, my boars puts SDA and SCL in Low, as it can be seen at my logic analyzer:

After receiving the whole ID, both SDA and SCL go to low. My emulator board keeps transmitting the rest of the message, but it does not show up because of the lock. Channel 2 has a sync signal that is asserted right after my board starts transmitting. The other 4 channels have the bits of a state indicator that helps me running through the flowchart. According to it, after the code above it tests if the module is in MASTER mode (if(ic & 0x20)), and the answer is still yes, even after cleaning up MST bit. Then, it checks if it has received ACK, and the answer is yes. Finally, it supposedly send the next byte.
It is funny that if the ID sent by the emulator does not match my board ID, my board releases the bus, even with the same tests going through (same program flow):

Here my board releases the bus after the first data byte transfer (0x11). Notice the Sync signal that goes low after the transfer is complete or the cycle is aborted.
Any ideas?
EDITED:
As I was using the copy of I2C_C1 to test Master mode (if(ic & 0x20)), the module was going through the Master mode branch of teh flowchart. I have corrected that, and now it follows the Slave mode branch, but the SDA and SCL lines still behave the same way.
I have changed my code to work on polling mode, as the frequency is low (approx. 5kHz), and now I can go step by step through the ISR. I noticed that the SDA line goes low even before the first test (line 7 of my code sample above). After I execute line 9 (switch ro Slave RX), it also drives SCL line to Low. And all of this problem only happens when I have a Slave ID match.