STM32Cube  Version 2.0
Create Projects for STM32F3 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 STM32303C-EVAL
I2C Peripheral I2C2
SCL Pin PF6
SDA Pin PA10

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

The STM32CubeMX configuration for STMicroelectronics STM32303C-EVAL Board with steps for Pinout, Clock, and System Configuration are listed below. Enter the values that are marked bold.

Pinout tab

  1. Configure peripheral
    • Peripherals I2C2: select=I2C
  2. Configure pins PF6 and PA10 as I2C2 peripheral alternative pins
    • Click in chip diagram on pin PF6 and select I2C2_SCL
    • Click in chip diagram on pin PA10 and select I2C2_SDA

Clock Configuration tab

  1. Configure I2C2 Clock
    • Setup "To I2C2 (MHz)" to match application requirements

Configuration tab

  1. Under Connectivity open I2C2 Configuration:
    • Parameter Settings: not used
    • User Constants: not used
    • NVIC Settings: enable interrupts
      Interrupt Table Enabled Preemption Priority Sub Priority
      DMA1 channel4 global interrupt ON 0 0
      DMA1 channel5 global interrupt ON 0 0
      I2C2 event global interrupt / I2C wake-.. ON 0 0
      I2C2 error interrupt ON 0 0
    • optional DMA Settings: setup DMA transfers for Rx and Tx (DMA is optional)
      Add - Select I2C2_RX: Stream=DMA1 Stream 5, Direction=Peripheral to Memory, Priority=Low
      DMA Request Settings Label Peripheral Memory
      Mode: Normal Increment Address OFF ON
      . Data Width Byte Byte
      Add - Select I2C2_TX: Stream=DMA1 Stream 4, Direction=Memory to Peripheral, Priority=Low
      DMA Request Settings Label Peripheral Memory
      Mode: Normal Increment Address OFF ON
      . Data Width Byte Byte
    • GPIO Settings: review settings
      Pin Name Signal on Pin GPIO output..GPIO mode GPIO Pull-up/Pull..Maximum out Fast Mode User Label
      PF6 I2C2_SCL n/a Alternate ..Pull-up High n/a .
      PA10 I2C2_SDA n/a Alternate ..Pull-up High n/a .
      Click OK to close the I2C2 Configuration dialog