STM32F4 I2Cv1 doesn't see the aknowledge

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

STM32F4 I2Cv1 doesn't see the aknowledge

Postby asiemasz » Fri Mar 24, 2023 4:08 pm

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Postby Giovanni » Fri Mar 24, 2023 4:51 pm

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

Postby psyco » Fri Mar 24, 2023 10:46 pm

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

Postby asiemasz » Sat Mar 25, 2023 2:27 pm

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Postby Giovanni » Sat Mar 25, 2023 3:05 pm

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

Postby asiemasz » Sun Mar 26, 2023 12:51 am

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: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Postby FXCoder » Sun Mar 26, 2023 11:38 am

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

Postby asiemasz » Sun Mar 26, 2023 4:36 pm

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

Postby asiemasz » Fri Mar 31, 2023 6:11 pm

Funny enough, I2C2 works with the same configuration.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32F4 I2Cv1 doesn't see the aknowledge

Postby Giovanni » Fri Mar 31, 2023 6:24 pm

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


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 5 guests