Skip to main content
Visitor II
July 8, 2019
Solved

About Pull-Up choice in STM32F4-DISCOVERY

  • July 8, 2019
  • 1 reply
  • 2171 views

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.

    This topic has been closed for replies.
    Best answer by oleksandr.karbivsky

    "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

    1 reply

    Visitor II
    July 8, 2019

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

    YAkseAuthor
    Visitor II
    July 8, 2019

    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.

    Visitor II
    July 8, 2019

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