Skip to main content
ISeed
Associate III
May 29, 2019
Question

STM32CUBEMX doesn't show GPIO Pull-up/Pull-down option for I2C

  • May 29, 2019
  • 4 replies
  • 7470 views

Hello,

I'm trying to imitate an I2C solution. I'm using STM32F100RB.

When selecting I2C ->

In the example, they have these GPIO settings for I2C pins:

Note the GPIO Pull-up/Pull-down option:

0690X000008a7jqQAA.jpg

Here is mine:

0690X000008a7kFQAQ.jpg

The CUBE version is identical.

The I2C configuration is identical.

What could be the reason?

Thanks!

This topic has been closed for replies.

4 replies

Khouloud ZEMMELI
ST Employee
May 29, 2019

​Hello @ISeed​ , It's reported internally for further check .

Best Regards,

Khouloud.

Khouloud ZEMMELI
ST Employee
May 29, 2019

@ISeed​  ​could you please send me the ioc exemple ?

ISeed
ISeedAuthor
Associate III
May 29, 2019

yes, of course. How do I send it to you?

Khouloud ZEMMELI
ST Employee
May 30, 2019

@ISeed​ select this Icon then ​upload the ioc exemple file.

Regards,

Khouloud.

0690X000008aD4KQAU.png

S.Ma
Principal
May 30, 2019

In any case, beyond the tools, nothing prevents you moving forward by programming the GPIO->PUPD registers directly.

2 lines of code, how long would it take to make it happen?

ISeed
ISeedAuthor
Associate III
May 30, 2019

Hi,

Do you have an example of this?

S.Ma
Principal
May 30, 2019

open stm32l4xx_hal_gpio.c and dig in:

 /* Activate the Pull-up or Pull down resistor for the current IO */
 temp = GPIOx->PUPDR;
 temp &= ~(GPIO_PUPDR_PUPD0 << (position * 2));
 temp |= ((GPIO_Init->Pull) << (position * 2));
 GPIOx->PUPDR = temp;

Want a pullup on PB3?

GPIOB->PUDR &= ~(0x03<<(3*2));

GPIOB->PUDR |= (0x01<<(3*2));

Want a pulldown on PB3?

GPIOB->PUDR &= ~(0x03<<(3*2));

GPIOB->PUDR |= (0x02<<(3*2));

Done, reading the ref man, 3 minutes, coding 2 minutes.

Brian D
Associate III
August 23, 2022

But this workaround is not a good solution, as the user codes will be wiped off whenever the IOC is compiled. The pull up done in CubeMX is a better choice.

Brian

alister
Senior III
August 24, 2022

It's a workaround, but that's ok. If your work's important, version-control it. And after any cube-change just revert any of its changes you don't want