Skip to main content
Theo Hussey
Associate
June 6, 2018
Question

STM32L496 I2C1 PA9 PA10 stuck low

  • June 6, 2018
  • 4 replies
  • 1883 views
Posted on June 06, 2018 at 12:49

I am having problems configuring the I2C1 gpio pins on the STM32L496 on pins PA9 and PA10.

After the gpios are configured the SCL and SDA lines go from a high level to a low level, which is unexpected. After configuration of the I2C peripheral itself the lines remain low and no data can be observed on the lines.

I have tried the same configuration using I2C2 on PB10 and PB11 and this works fine with the I2C lines remaining high after gpio configuration, and the peripheral can control the lines.

This is my configuration for the GPIO. Is there anything additional I need to enable, or do I have something wrong here?

I have tried configuring the lines as  od outputs and I can toggle the line, so i don't think it is a hardware issue.

Thanks

LL_AHB2_GRP1_EnableClock

(LL_AHB2_GRP1_PERIPH_GPIOA);

LL_GPIO_SetPinMode

(GPIOA, LL_GPIO_PIN_9, LL_GPIO_MODE_ALTERNATE);

LL_GPIO_SetAFPin_8_15

(GPIOA, LL_GPIO_PIN_9, LL_GPIO_AF_4);

LL_GPIO_SetPinSpeed

(GPIOA, LL_GPIO_PIN_9, LL_GPIO_SPEED_FREQ_HIGH);

LL_GPIO_SetPinOutputType

(GPIOA, LL_GPIO_PIN_9, LL_GPIO_OUTPUT_OPENDRAIN);

LL_GPIO_SetPinPull

(GPIOA, LL_GPIO_PIN_9, LL_GPIO_PULL_UP);

LL_GPIO_SetPinMode

(GPIOA, LL_GPIO_PIN_10, LL_GPIO_MODE_ALTERNATE);

LL_GPIO_SetAFPin_8_15

(GPIOA, LL_GPIO_PIN_10, LL_GPIO_AF_4);

LL_GPIO_SetPinSpeed

(GPIOA, LL_GPIO_PIN_10, LL_GPIO_SPEED_FREQ_HIGH);

LL_GPIO_SetPinOutputType

(GPIOA, LL_GPIO_PIN_10, LL_GPIO_OUTPUT_OPENDRAIN);

LL_GPIO_SetPinPull

(GPIOA, LL_GPIO_PIN_10, LL_GPIO_PULL_UP);

#i2c #stm32l4
This topic has been closed for replies.

4 replies

Technical Moderator
June 6, 2018
Posted on June 06, 2018 at 13:38

Hello

power.graphic

,

You can check your code with the I2C example and compare the I2C setting:

STM32Cube_FW_L4_V1.0\Projects\NUCLEO-L496ZG\Examples_LL\I2C

With Regards,

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
Theo Hussey
Associate
June 6, 2018
Posted on June 06, 2018 at 14:43

Hi Imen, I have looked at the I2C examples and I based my code off of these but they do not use PA9 and PA10. Clearly this should be easy to port over, and indeed I have managed to get 

I2C2 on PB10 and PB11 working fine. However with PA9 and PA10 the I2C lines are immediately pulled low when I connect them to alternate function 4.

0690X0000060LAYQA2.png
AvaTar
Senior III
June 6, 2018
Posted on June 06, 2018 at 15:08

Do you enable the clock to the I2C1 peripheral ?

Theo Hussey
Associate
June 6, 2018
Posted on June 06, 2018 at 15:23

I enable the I2C1 clock after setting up the GPIOs like in the examples. I don't think the lines should be pulled low even if the I2C peripheral is disabled. After the I2C clock is enabled the lines remain low.

AvaTar
Senior III
June 6, 2018
Posted on June 06, 2018 at 15:56

And there is nothing else on the pins that could pull it down ?

Like other circuitry, or attached I2C slaves ?

Just to make sure.

I have never used Cube or LL (apart from building a few examples), nor do I have a L4xx.

Theo Hussey
Associate
July 27, 2018

Looking at the datasheet further I have noticed that it does not show pins PA9 and PA10 as supporting I2C as an alternate function in table 15.

Can ST confirm that this is the case, as in table 16 it shows that PA9 and PA10 are connected to I2C1.

0690X0000060OkCQAU.png

0690X0000060OkMQAU.png

Theo Hussey
Associate
August 3, 2018

@Imen DAHMEN​  Can you comment on this?