Skip to main content
NASI
Associate III
August 13, 2021
Question

I2C2 doesn't work

  • August 13, 2021
  • 2 replies
  • 1033 views

Hello,

I am working with a custom board, using STM32F105VC.

The board has some LED drivers, which they use I2C1 and I2C2.

I2C1 works fine but I2C2 doesn't work. Configuration for both I2C are the same.

 hi2c2.Instance = I2C2;

 hi2c2.Init.ClockSpeed = 100000;

 hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;

 hi2c2.Init.OwnAddress1 = 0;

 hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;

 hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;

 hi2c2.Init.OwnAddress2 = 0;

 hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;

 hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;

 if (HAL_I2C_Init(&hi2c2) != HAL_OK)

 {

  Error_Handler();

 }

Do I need to enable something else?

In clock configuration, there is no setting for I2C1 and I2C2 peripherals. Why? (picture is attached)

Anyone can help me?

Thank you.

This topic has been closed for replies.

2 replies

ST Technical Moderator
August 13, 2021

Hello @NASI​ ,

Did you checked the pins assignment/configuration and jumpers?

Have a look to the errata sheet related to the devices to check if you have the same conditions as described in the doc and have an impact.

Please keep me informed about your update.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
T J
Senior III
August 14, 2021

make sure the pin speed is set to high or very high.

make sure all 4 pins have pull ups.