cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496 I2C1 PA9 PA10 stuck low

Theo Hussey
Associate II
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
9 REPLIES 9
Imen.D
ST Employee
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.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
AvaTar
Lead
Posted on June 06, 2018 at 15:08

Do you enable the clock to the I2C1 peripheral ?

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
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.

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.

Posted on June 06, 2018 at 19:27

There are attached devices, but I have now been able to verify that they are working OK by bridging the 2 I2C ports so I can use I2C2 to talk to the devices. 

Posted on June 06, 2018 at 22:35

Read back and check GPIO registers if they contain what you want them.

Also try to reset I2C in RCC reset register.

JW

Theo Hussey
Associate II

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 II

@Imen DAHMEN​  Can you comment on this?