STM32Cube  Version 2.0
Create Projects for STM32H7 Series with STM32Cube HAL and STM32CubeMX
 All Files Functions Variables Macros Pages
CMSIS-Driver I2C Setup

The CMSIS-Driver I2C requires:

  • Setup of I2Cx input clock
  • Setup of I2Cx in I2C mode with optional DMA for Rx and Tx transfers

The example below uses correct settings for STM32H743I-EVAL:

  • I2C1 Mode: I2C

For different boards, refer to the hardware schematics to reflect correct setup values.

The STM32CubeMX configuration steps for Pinout, Clock, and System Configuration are listed below. Enter the values that are marked bold.

Pinout tab

  1. Configure mode
    • Peripherals I2C1: Mode=I2C
  2. Configure pin PH7 and pin PH8 as I2C3 peripheral alternative pins
    • Click in chip diagram on pin PH7 and select I2C3_SCL
    • Click in chip diagram on pin PH8 and select I2C3_SDA

Clock Configuration tab

  1. Configure I2C1 Clock
    • Setup "To I2C1,2,3 (MHz)" to match application requirements

Configuration tab

  1. Under Connectivity open I2C1 Configuration:

    • optional DMA Settings: setup DMA transfers for Rx and Tx
      Add - Select I2C1_RX: Stream=DMA1 Stream 0, Direction=Peripheral to Memory, Priority=Low
      DMA Request Settings Label Peripheral Memory
      Mode: Normal Increment Address OFF ON
      Use Fifo OFF Threshold: Full Data Width Byte Byte
      . Burst Size Single Single
      Add - Select I2C1_TX: Stream=DMA1 Stream 1, Direction=Memory to Peripheral, Priority=Low
      DMA Request Settings Label Peripheral Memory
      Mode: Normal Increment Address OFF ON
      Use Fifo OFF Threshold: Full Data Width Byte Byte
      . Burst Size Single Single
    • GPIO Settings: review settings, no changes required
      Pin Name Signal on Pin GPIO mode GPIO Pull-up/Pull..Maximum out User Label
      PB6 I2C1_SCL Alternate Pull-up High .
      PB7 I2C1_SDA Alternate Pull-up High .
    • NVIC Settings: enable interrupts
      Interrupt Table Enable Preemption Priority Sub Priority
      DMA1 stream0 global interrupt ON 0 0
      DMA1 stream1 global interrupt ON 0 0
      I2C1 event interrupt ON 0 0
      I2C1 error interrupt ON 0 0
    • Parameter Settings: not used
    • User Constants: not used

    Click OK to close the I2C1 Configuration dialog