cancel
Showing results for 
Search instead for 
Did you mean: 

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

ISeed
Senior

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!

11 REPLIES 11
Khouloud ZEMMELI
ST Employee

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

Best Regards,

Khouloud.

Khouloud ZEMMELI
ST Employee

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

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

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

Regards,

Khouloud.

0690X000008aD4KQAU.png

S.Ma
Principal

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?

Hi,

Do you have an example of this?

Certainly, here it is

​This is your ioc file , could you please share the "example" ioc file where did you find GPIO Pull-up/Pull-down option ?

Thanks!

Khouloud.

S.Ma
Principal

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.