AnsweredAssumed Answered

STM32L496 I2C1/3 cannot work on GPIOG port.

Question asked by mei.raymond on Apr 8, 2018
Latest reply on Apr 13, 2018 by mei.raymond

L496 port G includes two I2C- PG13/14 I2C1 and PG7/8 I2C3. But the two I2C cannot output and the oscilloscope does not display waveform.

I2C1/I2C3 can work correctly if they are mapped to other ports. So I think the I2C1/I2C3 modules are ok in L496.
On the other hand, if I set PG13/14 and PG7/8 pin mode as GPIO output, they can work well. So the GPIOG module is ok.

So what is the problem with GPIOG I2C? I know Port G[15:2] are independent from other ports. But I connect Vddio2 to Vdd in the test. Please see the code below.

 

Init Code:
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOG);
HAL_PWREx_EnableVddIO2();

LL_GPIO_SetPinMode(GPIOG, LL_GPIO_PIN_13, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetAFPin_0_7(GPIOG, LL_GPIO_PIN_13, LL_GPIO_AF_4);
LL_GPIO_SetPinSpeed(GPIOG, LL_GPIO_PIN_13, LL_GPIO_SPEED_FREQ_HIGH);
LL_GPIO_SetPinOutputType(GPIOG, LL_GPIO_PIN_13, LL_GPIO_OUTPUT_OPENDRAIN);
LL_GPIO_SetPinPull(GPIOG, LL_GPIO_PIN_13, LL_GPIO_PULL_UP);
LL_GPIO_SetPinMode(GPIOG, LL_GPIO_PIN_14, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetAFPin_0_7(GPIOG, LL_GPIO_PIN_14, LL_GPIO_AF_4);
LL_GPIO_SetPinSpeed(GPIOG, LL_GPIO_PIN_14, LL_GPIO_SPEED_FREQ_HIGH);
LL_GPIO_SetPinOutputType(GPIOG, LL_GPIO_PIN_14, LL_GPIO_OUTPUT_OPENDRAIN);
LL_GPIO_SetPinPull(GPIOG, LL_GPIO_PIN_14, LL_GPIO_PULL_UP);

 

Read Code:
LL_I2C_Enable(I2C1);
LL_I2C_HandleTransfer(I2C1, add, LL_I2C_ADDRSLAVE_7BIT, 2, LL_I2C_MODE_AUTOEND, LL_I2C_GENERATE_START_READ);
while (!LL_I2C_IsActiveFlag_STOP(I2C1))
{
if (LL_I2C_IsActiveFlag_RXNE(I2C1))
{
i2c1Ctx.rxBuffer[0] = LL_I2C_ReceiveData8(I2C1);
}
}
LL_I2C_ClearFlag_STOP(I2C1);

Outcomes