Skip to main content
AVoro.19
Visitor II
October 23, 2020
Question

Wrong pinout configuration with LL_GPIO_Init()

  • October 23, 2020
  • 2 replies
  • 737 views

 GPIO_InitStruct.Pin = I2C1_SCL_Pin|I2C1_SDA_Pin;

 GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;

 GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;

 GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;

 LL_GPIO_Init(GPIOB, &GPIO_InitStruct);

Code above makes pins I2C1_SCL_Pin and I2C1_SDA_Pin configured as Output Push-pull.

(can be observed in SFRs window, when debugging)

This causes wrong I2C behavior, when receiving ADDR ACK

conditions:

STM32CubeIDE Version: 1.4.2

chip: stm32f103CB

I2C configuration, including GPIO setting, generated by device configuration tool.

SDA is on PB7

SCL is on PB6

Fix (workaround): Configure pins using registers. Adding following code makes GPIO configuration correct and I2C function properly:

GPIOB->CRL |= (GPIO_CRL_CNF6_0|GPIO_CRL_CNF6_1);

GPIOB->CRL |= (GPIO_CRL_CNF7_0|GPIO_CRL_CNF7_1);

This topic has been closed for replies.

2 replies

Amel NASRI
Technical Moderator
October 27, 2020

Hi @AVoro.19​ ,

Thank you for bringing this up.

This came up in the last patch of STM32CubeF1 package. It is already reported and explained here.

This will be fixed by our development team.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Amel NASRI
Technical Moderator
November 2, 2020

Hi @AVoro.19​ ,

The issue should be already fixed with the current patch (1.8.3) of STM32CubeF1.

Could you please check this on your side and confirm that the problem initially faced is no more there?

Thanks

Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.