AnsweredAssumed Answered

LPC82x I2C freeze/hang

Question asked by Kris Sielski on Apr 11, 2018
Latest reply on Apr 11, 2018 by Victor Jimenez

I am using the LPC824 with LPCOpen and if I attempt more than one I2C access in a row, the I2C hangs.

 

Using the LPC824 example project "periph_i2cm_polling" and modifying it to do 2 consecutive reads from a Si7021 (Humidity  and temp), it consistently hangs in the LPCOpen driver code.

 

<< i2cm_8xx.c >>

 

/* Transmit and Receive data in master mode */
uint32_t Chip_I2CM_XferBlocking(LPC_I2C_T *pI2C, I2CM_XFER_T *xfer)
{
    uint32_t ret = 0;
    /* start transfer */
    Chip_I2CM_Xfer(pI2C, xfer);

    while (ret == 0) {
        /* wait for status change interrupt */
        while (!Chip_I2CM_IsMasterPending(pI2C)) {}    <<<<<<< HANGS HERE ON THE SECOND READ
        /* call state change handler */
        ret = Chip_I2CM_XferHandler(pI2C, xfer);
    }
return ret;
}

 

Even if I add a small delay (10ms or so) in between reads, it still freezes once in a while.

 

I have tried LPCOPEN  2.19 (default for MCUXpresso v10.1.1) and 3.02

 

Is there a cause/fix for this condition?

Outcomes