AnsweredAssumed Answered

Issue while initialising I2C0 for LPC43S67

Question asked by Neha Gandhi on Feb 1, 2017
Latest reply on Feb 8, 2017 by Neha Gandhi

Hi LPC WARE LPCware Support

I am using LPC43S67 micro controller for firmware development. I am using I2C0 library Initialization functions provided in LPC open source for  configuring MPU60X0 as below

#define DEFAULT_I2C             I2C0
#define DEFAULT_MPU60X0_ADDR     0xD1
#define PWR_MGMT_1               0x6B
#define I2C_DEFAULT_SPEED        100000

        SystemCoreClockUpdate();
        Board_Init();

                      Board_I2C_Init(I2C0)

                                {                                                                                                                                                       
                                   Chip_SCU_I2C0PinConfig(I2C0_STANDARD_FAST_MODE);

                                   }

 

        Chip_I2C_Init(I2C0);
        Chip_I2C_SetClockRate(I2C0,I2C_DEFAULT_SPEED);

 

        if(Chip_I2C_SetMasterEventHandler(I2C0,Chip_I2C_EventHandler));
            NVIC_EnableIRQ(I2C0_IRQn);

       Chip_I2C_MasterSend(i2cDev, DEFAULT_MPU60X0_ADDR, pwr_mgmt_data, 2);

 

I am having arbitration lost error while executing below code

int Chip_I2C_MasterSend(I2C_ID_T id, uint8_t slaveAddr, const uint8_t *buff, uint8_t len)
{
     I2C_XFER_T xfer = {0};
    xfer.slaveAddr = slaveAddr;
    xfer.txBuff = buff;
    xfer.txSz = len;
    while (Chip_I2C_MasterTransfer(id, &xfer) == I2C_STATUS_ARBLOST) {}
    return len - xfer.txSz;
}

 

But I am not getting Clock on the SCL0 PMOD pin. I have provided pull up 1kOhm resistor on PMOD SDA0 and SCL0 pins as well.

 

Do I need to mention  explicitly in pin configuration for open drain i/o?

 

I am able to read the MPU values through I2C1 and getting the clock properly for I2C1 with below code.

 

#define I2C_DEFAULT_SPEED        100000

 

        Board_I2C_Init(I2C1);
        Chip_I2C_Init(I2C1);
        Chip_I2C_SetClockRate(I2C1,I2C_DEFAULT_SPEED);

 

        if(Chip_I2C_SetMasterEventHandler(I2C1,Chip_I2C_EventHandler));
            NVIC_EnableIRQ(I2C1_IRQn);

 

Is there any issue in the source code used while initializing I2C0 or there is any bug in LPC open source code for I2C0?

 

I have compared the code for I2C1 and I2C0, I didn't notice any specific change of registers as well except the value of event handler

In case of I2C0 -> event handler -> 0x1a0015f1

                  I2C1 -> event handler -> 0x1a0015ff.

 

I have already spent lot of time in debugging the issue, now i am not sure how to proceed and debug it further?

Outcomes