STM32H743 I2C

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

Moderators: RoccoMarco, barthess

Amir1980
Posts: 12
Joined: Tue Jan 03, 2023 4:03 pm
Has thanked: 2 times

STM32H743 I2C

Postby Amir1980 » Sat Feb 04, 2023 4:49 pm

Hi,

I have to read data from a BMP180 sensor, it's on my custom board, PD12,PD13 pins, I2C4. how to use i2cDriver? how to config i2cv3?

I didn't found any H7 i2c example.

Regards,
Amir.

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: STM32H743 I2C

Postby Giovanni » Sat Feb 04, 2023 6:03 pm

Hi,

Look of other I2C examples, API is the same. You could try to ask on the Discord server, probably somebody already used it on h7.

Giovanni

Amir1980
Posts: 12
Joined: Tue Jan 03, 2023 4:03 pm
Has thanked: 2 times

Re: STM32H743 I2C

Postby Amir1980 » Thu Feb 09, 2023 5:44 pm

Dear Giovanni,

I didn't found any example using i2c on H7 device, the problem is not the i2cDriver, my problem is the i2c config:

Code: Select all

static const I2CConfig i2cConfig = {
      OPMODE_I2C,
      100000,
      STD_DUTY_CYCLE,
};


the compiler replied: main.c:59:7: error: 'OPMODE_I2C' undeclared here (not in a function)
and main.c:61:7: error: 'STD_DUTY_CYCLE' undeclared here (not in a function)

Regards,
Amir.

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: STM32H743 I2C

Postby Giovanni » Thu Feb 09, 2023 6:11 pm

Hi,

That configuration structure is for I2Cv1, the I2Cv2/I2Cv3 structure is different:

Code: Select all

struct hal_i2c_config {
  /**
   * @brief   TIMINGR register initialization.
   * @note    Refer to the STM32 reference manual, the values are affected
   *          by the system clock settings in mcuconf.h.
   */
  uint32_t        timingr;
  /**
   * @brief   CR1 register initialization.
   * @note    Leave to zero unless you know what you are doing.
   */
  uint32_t        cr1;
  /**
   * @brief   CR2 register initialization.
   * @note    Only the ADD10 bit can eventually be specified here.
   */
  uint32_t        cr2;
};


Note that those are register values, the documentation is on the STM32 reference manual, especially "TIMINGR" is critical. Values can be written as numeric constant or using ST-defined macros present in the STM32 CMSIS header for your device, see under /os/common/ext/ST and pick yours.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 15 guests