cancel
Showing results for 
Search instead for 
Did you mean: 

About Pull-Up choice in STM32F4-DISCOVERY

YAkse
Associate III

Hey, I have an STM32F4 discovery board which have a user button on it. I am setting button pin as input and when I try pull-down, it works as it should be,

HIGH when pressed

LOW when not pressed

But if I do not know wrong, when I choose pull-up then it should be

LOW when pressed

HIGH when not pressed

But this code below, gives me an always ON led , whether i am pressing or not.

 if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0))

  HAL_GPIO_WritePin(GPIOD, LD4_Pin, 1);

else

HAL_GPIO_WritePin(GPIOD, LD4_Pin, 0);

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

"If it is not working, then why is unpressed button resulting in a HIGH output ? ( When the button is configured as pull-up )"

Because the button is configured as pull-up (you answered on self question).

When button pressed it shorts with VCC. Check board schematic))

"Also in CubeMX, why ST gives me opportunity to choose pull-up then ?"

CubeMX give you opportunity to choose all functions, this don`t depend from board.

Special for you: 0690X000009YVhFQAW.png

View solution in original post

6 REPLIES 6

Hi. STM32F4-Discovery have a pull-down resistor (R39 220 KOhm) on board. Page 31 of user manual. Typical in-chip pull-up resistor is 40 KOhm. In this case voltage with unpressed button is 2.53 V (logic one).

Hey, thanks for the answer. But I am also saying that it should be and it is HIGH with unpressed button. My problem is with pressed button case at pull-up configuration.

Pull-up configuration dont work with this board. Because when button pressed pin state is high. Check board schematic.

YAkse
Associate III

If it is not working, then why is unpressed button resulting in a HIGH output ? ( When the button is configured as pull-up )

Also in CubeMX, why ST gives me opportunity to choose pull-up then ?

Thanks anyway.

"If it is not working, then why is unpressed button resulting in a HIGH output ? ( When the button is configured as pull-up )"

Because the button is configured as pull-up (you answered on self question).

When button pressed it shorts with VCC. Check board schematic))

"Also in CubeMX, why ST gives me opportunity to choose pull-up then ?"

CubeMX give you opportunity to choose all functions, this don`t depend from board.

Special for you: 0690X000009YVhFQAW.png

YAkse
Associate III

Hey, thank you so much.

With your last eddition of that figure, now I understand it. At first I thought that R39 220K is the pull-down resistor. Which is not according to your figure.