Issue while initialising I2C0 for LPC43S67

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue while initialising I2C0 for LPC43S67

Jump to solution
2,037 Views
nehagandhi
Contributor II

Hi lpcware 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?

Labels (4)
0 Kudos
1 Solution
1,360 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Neha Gandhi,

    It seems you are testing it on the LPCXpresso 43S67 board.

   This board already have the pull up, you don't need to add it. J3_9 is I2C0_SCL, J3_10 is the I2C0_SDA .

pastedImage_2.png

  Did you test the lpcopen code for LPC43S67? I have test it on my LPCXpresso 43S67 board, I can get the I2C wave in the I2C0 pin.

  So, you can check the according code on your side, the official code is using the I2C0 :

http://www.nxp.com/assets/downloads/data/en/software/lpcopen_2_20_lpcxpresso_nxp_lpcxpresso_4337.zip 

Folder:\lpcopen_2_20_lpcxpresso_nxp_lpcxpresso_4337\periph_i2cm_interrupt

Please try that code initialization.

This is the periph_i2cm_interrupt test wave, I didn't add the slaver.

pastedImage_3.png


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

8 Replies
1,360 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Neha Gandhi,

  Please refer to the lpcopen I2C0 code and my test result in the above reply.

  Any question, please let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,360 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Neha Gandhi,

  From the lpc43s37 user manual,  you can find this remark:

pastedImage_1.png

pastedImage_2.png

Did you take care of it?

Besides, please change the external pull-up resistor to 4.7K to 10K, then try it again.

After you test it, if you still have question, please also give me your I2C0 wave in the I2C0 pin.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,360 Views
nehagandhi
Contributor II

Hi @Kerry Zhou,

Did you get time to look on my issue?

It of high importance as the whole project got struck due this issue.

Kindly let me know if there is any errata or any issue or any hardware configuration required.

0 Kudos
1,360 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Neha Gandhi,

   I will test it on my side, any updated information will let you know ASAP.

   Now, please wait patiently!.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,360 Views
nehagandhi
Contributor II

Hi @kerry Zhou,

I have done the below configuration for I2C0

#define I2C0_STANDARD_FAST_MODE        (1 << 3 | 1 << 11)

I have tried using #define I2C0_STANDARD_FAST_MODE        (1 << 3 | 1 << 7 | 1 << 11) as well

Chip_SCU_I2C0PinConfig(I2C0_STANDARD_FAST_MODE);

STATIC INLINE void Chip_SCU_I2C0PinConfig(uint32_t I2C0Mode)
{
    LPC_SCU->SFSI2C0 = I2C0Mode;
}

But the clock is going low while executing the below function

STATIC INLINE void startMasterXfer(LPC_I2C_T *pI2C)
{
    /* Reset STA, STO, SI */
    pI2C->CONCLR = I2C_CON_SI | I2C_CON_STA | I2C_CON_AA;

    /* Enter to Master Transmitter mode */
    pI2C->CONSET = I2C_CON_I2EN | I2C_CON_STA;               <-- Clock will go to low after executing this statement
}

I am getting the below values in these registers

CONCLR = 1101000

CONSET = 1101000

I use to lost the control while executing the below statement after this function call

iic->mEvent(id, I2C_EVENT_WAIT);

I have connected 10K resistor in place of 1K as suggested by you. But nothing works out.

As the clock goes low after executing the above statement, I am not able to generate any particular waveform.

Please let me know, If i have to do anything else further on this.

0 Kudos
1,359 Views
nehagandhi
Contributor II

Hi @kerry zhou,

I have attached the image of my pull up resistor connection.

0 Kudos
1,361 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Neha Gandhi,

    It seems you are testing it on the LPCXpresso 43S67 board.

   This board already have the pull up, you don't need to add it. J3_9 is I2C0_SCL, J3_10 is the I2C0_SDA .

pastedImage_2.png

  Did you test the lpcopen code for LPC43S67? I have test it on my LPCXpresso 43S67 board, I can get the I2C wave in the I2C0 pin.

  So, you can check the according code on your side, the official code is using the I2C0 :

http://www.nxp.com/assets/downloads/data/en/software/lpcopen_2_20_lpcxpresso_nxp_lpcxpresso_4337.zip 

Folder:\lpcopen_2_20_lpcxpresso_nxp_lpcxpresso_4337\periph_i2cm_interrupt

Please try that code initialization.

This is the periph_i2cm_interrupt test wave, I didn't add the slaver.

pastedImage_3.png


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,359 Views
nehagandhi
Contributor II

Hi Kerry,

The above code is helpful, thank you for timely reply.

0 Kudos