cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong pinout configuration with LL_GPIO_Init()

AVoro.19
Associate

 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);

2 REPLIES 2
Amel NASRI
ST Employee

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 Accept as Solution on the reply which solved your issue or answered your question.

Amel NASRI
ST Employee

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 Accept as Solution on the reply which solved your issue or answered your question.