i2c hitting debug panic

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

i2c hitting debug panic

Post 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]);
        }
    }
Last edited by Tabulous on Wed Mar 05, 2014 6:28 pm, edited 1 time in total.
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: i2c hitting debug panic

Post by Tabulous »

also to add, the first time through the loop, status is returned RDY_TIMEOUT, after this you get assert
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: i2c hitting debug panic

Post 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 2789 times
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: i2c hitting debug panic

Post by Giovanni »

Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: i2c hitting debug panic

Post 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 :-)
Post Reply