STM32F4 I2Cv1 doesn't see the aknowledge

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
asiemasz
Posts: 5
Joined: Fri Mar 24, 2023 4:01 pm

STM32F4 I2Cv1 doesn't see the aknowledge

Post by asiemasz »

Hi,
I'm trying to communicate with vl53l0x through the I2C interface. I checked both on an oscilloscope and logic analyzer and signals look good, but the software returns a not acknowledged status. I've seen some other topics about i2c issues on STM32F4 here and added pullup (4k7) to SDA and SCL lines, however, nothing is changing. I checked both fast and standard I2C modes.
While using STMCube and HAL both reading and writing to the device work (with the same pins configuration).
Pins are configurated with macros PAL_MODE_ALTERNATE(4), PAL_STM32_OSPEED_HIGHEST, PAL_STM32_OSPEED_HIGHEST and PAL_MODE_OUTPUT_OPENDRAIN. Any hints?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by Giovanni »

Hi,

I would check the physical connection, it is very critical, how log are wires for example?

Giovanni
psyco
Posts: 21
Joined: Fri May 22, 2020 1:40 am
Been thanked: 11 times

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by psyco »

Try this:

Code: Select all

PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN
asiemasz
Posts: 5
Joined: Fri Mar 24, 2023 4:01 pm

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by asiemasz »

psyco wrote:Try this:

Code: Select all

PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN

it is like that already.
Giovanni wrote:Hi,

I would check the physical connection, it is very critical, how log are wires for example?

Giovanni

Giovanni, wires are just regular short prototype connectors. As I said I tested the same configuration with STM32 Cube HAL and all works without errors.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by Giovanni »

Hi,

Are you using the correct address?

Note that in ChibiOS you need to pass the address field value without the RW bit, not the whole 1st byte value.

Giovanni
asiemasz
Posts: 5
Joined: Fri Mar 24, 2023 4:01 pm

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by asiemasz »

Giovanni wrote:Hi,

Are you using the correct address?

Note that in ChibiOS you need to pass the address field value without the RW bit, not the whole 1st byte value.

Giovanni

Yes, I also checked the signals from both chibios and Cube and they look the same - it has aknowledge.
Screenshot from the logic analyzer: https://ibb.co/3dKW6Wn
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by FXCoder »

Hi,
Is the I2C config something like this?

Code: Select all

const I2CConfig _i2cMainCfg = {
    OPMODE_I2C,
    50000,
    STD_DUTY_CYCLE,
};


I know this configuration works on F413 with BME280 configured for I2C use.
(Should be using dot notation for member access but this is old code).

--
Bob
asiemasz
Posts: 5
Joined: Fri Mar 24, 2023 4:01 pm

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by asiemasz »

FXCoder wrote:Hi,
Is the I2C config something like this?

Code: Select all

const I2CConfig _i2cMainCfg = {
    OPMODE_I2C,
    50000,
    STD_DUTY_CYCLE,
};


I know this configuration works on F413 with BME280 configured for I2C use.
(Should be using dot notation for member access but this is old code).

--
Bob

Yes, it looks the same for lower clock frequencies as well.
asiemasz
Posts: 5
Joined: Fri Mar 24, 2023 4:01 pm

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by asiemasz »

Funny enough, I2C2 works with the same configuration.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Post by Giovanni »

Strange, is it possible I2C1 pins are shorted or connected to something else on the board? defective device?

Unless it is a GPIO setting problem it should be an HW problem.

Giovanni
Post Reply