i2c SDA and SCL stuck in 0 state Topic is solved

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Lyris
Posts: 11
Joined: Thu Jun 20, 2019 11:58 am
Has thanked: 2 times

i2c SDA and SCL stuck in 0 state

Post by Lyris »

Hello,

I would like to connect my nucleo F446RE to an external imu sensor using i2c driver 1.
I have set the pins with the required pal mode and connected them to an logic analyzer.

After calling the two function below:
palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN); /* SCL */
palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN); /* SDA */

the pins goes to 0 and remain like this forever. I have no signal going on the i2c bus after doing:

Code: Select all

i2cStart(&I2CD1, &i2ccfg);
i2cAcquireBus(&I2CD1);
result = i2cMasterTransmitTimeout(&I2CD1,
                     LSM9DS1_AG,
                     tx_buf,
                     sizeof(tx_buf),
                     rx_buff,
                     count,
                     LSM9DS1_COMMUNICATION_TIMEOUT);
i2cReleaseBus(&I2CD1);
i2cErr = i2cGetErrors(&I2CD1);
i2cStop(&I2CD1);


The result of i2cErr is 0. Anyone has an idea why I cannot see anything on the bus ?
I also tried driver 2 without success. The serial driver 2 is working and I can send log to my computer.

Greetings,
Lyris
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: i2c SDA and SCL stuck in 0 state

Post by Giovanni »

Hi,

Do you have external pull up resistors?

Giovanni
Lyris
Posts: 11
Joined: Thu Jun 20, 2019 11:58 am
Has thanked: 2 times

Re: i2c SDA and SCL stuck in 0 state

Post by Lyris »

Hi Giovanni,

No the board is not connected to anything but the logic analyzer. I just wanted to check the signals.

Lyris
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: i2c SDA and SCL stuck in 0 state

Post by Giovanni »

If you set pins as open drain and have no external pull up then you can only see zero.

Try adding 1k resistors, more info here: https://en.wikipedia.org/wiki/Open_collector

Giovanni
Lyris
Posts: 11
Joined: Thu Jun 20, 2019 11:58 am
Has thanked: 2 times

Re: i2c SDA and SCL stuck in 0 state

Post by Lyris »

Make sense, thank you.
Post Reply