STM32Cube  Version 2.0
Create Projects for STM32L0 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 STM32L073Z-EVAL
I2C Peripheral I2C1
SCL Pin PB6
SDA Pin PB7

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

The STM32CubeMX configuration for STMicroelectronics STM32L073Z-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 I2C1 enable I2C
  2. Configure pins PB6 and PB7 as I2C1 peripheral alternative pins
    • Click in chip diagram on pin PB6 and select I2C1_SCL
    • Click in chip diagram on pin PB7 and select I2C1_SDA

Clock Configuration tab

  1. Configure I2C1 Clock
    • Setup "I2C1CLK (MHz)" to match application requirements

Configuration tab

  1. Under Connectivity open I2C1 Configuration:
    • Parameter Settings: not used
    • User Constants: not used
    • NVIC Settings: enable interrupts
      Interrupt Table Enabled Preemption Priority
      DMA1 channel 2 and channel 3 interrupts ON 0
      I2C1 event global interrupt / I2C1 wake-..ON 0
    • optional DMA Settings: setup DMA transfers for Rx and Tx (DMA is optional)
      Add - Select I2C1_RX: Stream=DMA1 Stream 3, Direction=Peripheral to Memory, Priority=Low
      DMA Request Settings Label Peripheral Memory
      Mode: Normal Increment Address OFF ON
      . Data Width Byte Byte
      Add - Select I2C1_TX: Stream=DMA1 Stream 2, 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, no changes required
      Pin Name Signal on Pin GPIO output..GPIO mode GPIO Pull-up/Pull..Maximum out Fast Mode User Label
      PB6 I2C1_SCL n/a Alternate ..Pull-up Very High Disable .
      PB7 I2C1_SDA n/a Alternate ..Pull-up Very High Disable .
      Click OK to close the I2C2 Configuration dialog