This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C address ( C5515 - Arduino Mega)

Hi there, I'm connecting an Arduino Mega to the C5515 via I2C and I'm having problems with the address I have to use.

The C5515 is the master and Arduino the slave.

From C5515 I call the follow funciton:

Int16 USBSTK5515_I2C_read( Uint16 i2c_addr, Uint8* data, Uint16 len )
{
    Int32 timeout, i;

    I2C_CNT = len;                    // Set length
    I2C_SAR = i2c_addr;               // Set I2C slave address
    I2C_MDR = MDR_STT                 // Set for Master Read
              | MDR_MST
              | MDR_IRS
              | MDR_FREE;

    USBSTK5515_wait( 10 );            // Short delay

    for ( i = 0 ; i < len ; i++ )
    {
        timeout = i2c_timeout;

        //Wait for Rx Ready 
        do
        {
            if ( timeout-- < 0 )
            {
                USBSTK5515_I2C_reset( );
                return -1;
            }
        } while ( ( I2C_STR & STR_RRDY ) == 0 );// Wait for Rx Ready

        data[i] = I2C_DRR;            // Read
    }

    I2C_MDR |= MDR_STP;               // Generate STOP

	USBSTK5515_waitusec(10);
    return 0;
}

And from Arduino I use the handler 'onRequest' from Wire.h to send the data I want to the C5515 (16 bytes each time). 'onRequest' is triggered when C5515 calls the function above.

At the beginning to know which address I had to use I used a scanner program for Arduino which gave me these results:

Scanning...
I2C device found at address 0x18 !
I2C device found at address 0x2F !
I2C device found at address 0x3C !
done

So the 0x18 is for the Audio CODEC and the 0x3C is for the OLED Display as stated in the c5515 Technical Reference pdf.

So I thought 0x2F was 'free' and I could use that address. But it didn't work well, the program collapses. 

Then I tried the address 0x30 and 0x31 (idk why, just to try) and it worked pretty well but with some instability though.

So, what address should I exactly use? Also I'm a bit confused on how i2c address works and how are assigned :S

Thank you in advance.

EDIT: Okay I found the problem, it has nothing to do with i2c address. At some point of the program, the C5515 board was doing too many requests in small period of time to the arduino that the I2c bus went crazy, I've just fixed it with a delay.