cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to change GPIO_Mode and GPIO PU/PD settings from Device configuration tool on STM32G0?

GCaso.2
Associate

When I assign a pin to a peripheral (e.g. comparator 3) the corresponding GPIO mode is fixed to Analog and cannot be changed. As a consequence, no pull-up or pull-down resistor can be inserted. By changing System.ioc with a text editor the correct code is generated and the device behaves as expected (pull-up register inserted)

PE7.GPIOParameters=GPIO_Label

changed to

PE7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode

Added rows:

PE7.GPIO_Mode=GPIO_MODE_AF_OD

PE7.GPIO_PuPd=GPIO_PULLUP

1 REPLY 1
Hl_st
ST Employee

The easier way to set pull-up or pull-down GPIO resistor is through direct register control in code:

GPIOE->PUPDR = (0x1 << (0x2U * 0x7));

where GPIOE is used GPIO port

           0x1 is for pull-up resistor (0x0 - no pull-up no pull-down, 0x2 pull-down)

           0x7 is the number of GPIO pin

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.