Page 1 of 1

i2c hitting debug panic

Posted: Wed Mar 05, 2014 5:29 pm
by Tabulous
Trying to read register from LIS3DH Accelerometer, and the code keeps hitting this Assert, where i2ccp->state is I2C_LOCKED ?

Device is a STM32F417IGH6


chDbgAssert(i2cp->state == I2C_READY,
"i2cMasterTransmitTimeout(), #1", "not ready");


Code: Select all

/*
 * I2C Config
 */
static const I2CConfig acccfg = {
    OPMODE_I2C,
    400000,
    FAST_DUTY_CYCLE_2,
};

    while(TRUE)
    {
        chThdSleepMilliseconds(500);

        txbuf[0] = 0x0F; // who am i reg, its fixed at 0x33;

        i2cAcquireBus(&I2CD1);
        status = i2cMasterTransmitTimeout(&I2CD1, 0x18, txbuf, 1, rxbuf, 2, tmo);
        i2cReleaseBus(&I2CD1);

        if(status == RDY_OK)
        {
            chprintf((BaseSequentialStream*)&SD6, "0x%.2X", rxbuf[0]);
        }
    }

Re: i2c hitting debug panic

Posted: Wed Mar 05, 2014 5:38 pm
by Tabulous
also to add, the first time through the loop, status is returned RDY_TIMEOUT, after this you get assert

Re: i2c hitting debug panic

Posted: Wed Mar 05, 2014 7:26 pm
by Tabulous
Ive got something working but not very happy abou the apparent bus contention, see attached file

DS0001.jpg
DS0001.jpg (38.89 KiB) Viewed 2791 times

Re: i2c hitting debug panic

Posted: Wed Mar 05, 2014 8:55 pm
by Giovanni

Re: i2c hitting debug panic

Posted: Thu Mar 06, 2014 9:39 am
by Tabulous
Giovanni wrote:Please try this guide: http://www.chibios.org/dokuwiki/doku.ph ... e_shooting

Giovanni


Hi Giovanni, the issue was not setting SDA line to Open Drain. I was kind of assuming this was set correctly when you select AF mode 4, but this is not the case.

Cheers :-)