stm32i2cstm32cubeidestm32cubemx

STM32F103 Switch I2C pins


Im using stm32f103c8t6 bluepill development board. I enabled I2C-2 in STM32CubeIDE. By default scl pin is assigned to PB10 and sda pin is assigned to PB11. But I need to switch them as SCL PB11, SDA PB10.

I Already tried change it from SystemCore -> GPIO -> I2C window. but its does not change.

Image


Solution

  • It is not possible to remap the I2C pins that way. Each pin can be configured to GPIO and to some peripheral function. The possible configurations are described in the datasheet of the MCU. PB10 can be configured as GPIO, I2C2_SCL, USART3_TX and TIM2_CH3. It does not support the I2C2_SDA function. There is the same problem with PB11, it cannot be connected to the SDA signal of the I2C2 peripheral.

    If you absolutely must implement that configuration, you can configure the pins to GPIO and implement the I2C protocol through software bit-banging. Depending in your application, it might be a good solution.