STM32Cube  Version 2.0
Create Projects for STM32F2 Series with STM32Cube HAL and STM32CubeMX
 All Files 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

Valid settings for various evaluation boards are listed in the table below:

Peripheral Resource MCBSTM32F200 STM3220G-EVAL
I2C Mode I2C1: I2C I2C1: I2C
SCL pin PB8 PB6
SDA pin PB9 PB9

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

The STM32CubeMX configuration for MCBSTM32F200 with 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

Clock Configuration tab

  1. Configure APB1 clock
    • Setup "APB1 peripheral clocks (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 6, 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
      PB8 I2C1_SCL Alternate Pull-up High .
      PB9 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 stream6 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