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 As slave, Using F28035

Other Parts Discussed in Thread: CONTROLSUITE

Dear All:

              I am working on a project need to config I2C as a slave, to get datas from the Master. But I can get nothing, and the BB bit always be 1.

I can not even jump to the isr!   When I config it as a Master to read eeprom, it works fine.  But as a slave, it does not work.   Please help!

Here is my code:

void InitI2C(void)
{
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;     // I2C
    EDIS;
    // Initialize I2C-A:
    InitI2CGpio();
    // Initialize I2C
    I2caRegs.I2CMDR.bit.IRS = 0;
    
    // Initialize I2C
    I2caRegs.I2COAR = 0x007C;        // Own address
    I2caRegs.I2CPSC.all = 5;        // Prescaler - need 7-12 Mhz on module clk
    I2caRegs.I2CCLKL = 10;            // NOTE: must be non zero
    I2caRegs.I2CCLKH = 5;            // NOTE: must be non zero

    I2caRegs.I2CSTR.bit.RRDY = 1;    // Clear flag
    I2caRegs.I2CIER.bit.RRDY = 1;   // Enable Receive Interrupt
    I2caRegs.I2CIER.bit.SCD = 1;
    I2caRegs.I2CIER.bit.NACK = 1;

    I2caRegs.I2CMDR.all = 0x0020;    // Take I2C out of reset
                                       // Stop I2C when suspended

     EALLOW; 
     PieVectTable.I2CINT1A = &i2c_int1a_isr;
  
     PieCtrlRegs.PIEIER8.bit.INTx1 = 1;
     IER |= M_INT8;
   
     PieCtrlRegs.PIEACK.all = 0xffff;
     EDIS;
     EINT;                                  // Enable Global interrupt INTM
     ERTM;        
}

interrupt void i2c_int1a_isr(void)     // I2C-A
{
    Uint16 IntSource;
    Uint16 i;
    Uint16 uiFrameHead;
    float fTmp;
   // Read interrupt source
    IntSource = I2caRegs.I2CISRC.bit.INTCODE & 0x7;
    
    switch(IntSource)
    {
        case I2C_NO_ISRC:   // =0
            break;

        case I2C_ARB_ISRC:  // =1
            break;

        case I2C_NACK_ISRC: // =2
            break;

        case I2C_ARDY_ISRC: // =3
            break;

        case I2C_RX_ISRC:   // =4
            uiI2CData[uiI2CGetCount++] = I2caRegs.I2CDRR;
                break;

        case I2C_TX_ISRC:   // =5

            break;

        case I2C_SCD_ISRC:  // =6
            break;

        case I2C_AAS_ISRC:  // =7
            break;
    
        default:
            break; // Halt on invalid number.
    }

   // Enable further I2C (PIE Group 8) interrupts by acknowledging this one.
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
    }
}